WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
how to MOVE or copy folders containing subfolders (Read 2862 times)
cptfisher
YaBB Newbies
*
Offline



Posts: 2
how to MOVE or copy folders containing subfolders
Mar 19th, 2014 at 9:48am
 
hello i have a question

so basically i have a path in my server drive dedicated as an ftp service where my mates upload their stuff for backup purpose. As the net speed where i live is pretty bad ( 1 megabit) my mate upload  their backup rarred in X part of Y MB
with a sfv file. i have installed a script in my ftp service that reads the sfv file and create a subfolder as a " progression bar"

for istance when my Friend Alex uploads his online match replay he rars the video upload the sfv and the rars and that what happens in the tree of my drive :
(lets suppose that the VOLUME of the drive is F)

F:
-ALEX
-MATCH REPLAY
  +1% of MATCH REPLAY - 1 file of 3 - 5 MB
   match.replay.part00.rar
   match.replay.part01.rar.missing
   match.replay.rar.missing
   match.replay.sfv
+FRIEND X
+FRIEND Y
+FRIEND N

after many hours that alex has finished upload  hr is what appens in the tree of  F DRIVE

F:
-ALEX
-MATCH REPLAY
  +100% of MATCH REPLAY - 3 file of 3 - 500 MB
   match.replay.part00.rar
   match.replay.part01.rar
   match.replay.rar
   match.replay.sfv
+FRIEND X
+FRIEND Y
+FRIEND N


there is where whatch directory to act

i want that it scans the path f:\alex
when it detects a subfolder containing a subfolder with name containing value 100% it moves or copies (it doesnt matter copy or move as when moved to dest path i will have another script that copies it for redundancy as i know that the file in dest path are always complete:) ) to a destination path like d:\Complete happening like this

F:
+ALEX
+FRIEND X
+FRIEND Y
+FRIEND N

D:
-COMPLETE
-ALEX
  -MATCH REPLAY
   +100% of MATCH REPLAY - 3 file of 3 - 500 MB
    match.replay.part00.rar
    match.replay.part01.rar
    match.replay.rar
    match.replay.sfv


thank you and regards
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: how to MOVE or copy folders containing subfolders
Reply #1 - Mar 19th, 2014 at 12:19pm
 
So you monitor some "upper" directory, perhaps called
F:\AllFriends

That directory has a folder for each friend that uploads files to you, for example
F:\AllFriends\Alex
F:\AllFriends\John
...

They upload "titles", in your example "MATCH REPLAY":
F:\AllFriends\Alex\MATCH REPLAY

directly inside this folder is a "dummy folder" that indicates progress (the "100% folder in your example). Directy inside the title folder are the files to copy/move:
F:\AllFriends\Alex\MATCH REPLAY\file1.rar
F:\AllFriends\Alex\MATCH REPLAY\file2.sfv

When a folder with "100%" in its name is detected, all the files must be copied to some other destination. F:\AllFiles for example. I guess they must be copied to some specific (new?) subfolder? Perhaps
F:\AllFiles\<name of friend>\<name of title>
So in your example, the files are copied to
F:\AllFiles\Alex\MATCH REPLAY

Should be possible with a little script you run using the "Run any bat file" task. I will be happy to write the script for you. Is my understanding (above) correct?



Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
cptfisher
YaBB Newbies
*
Offline



Posts: 2
Re: how to MOVE or copy folders containing subfolders
Reply #2 - Mar 19th, 2014 at 12:30pm
 
yeah you understood perfectly sir.contact me with private message for details please
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: how to MOVE or copy folders containing subfolders
Reply #3 - Mar 19th, 2014 at 12:33pm
 
Just send me an email and reference this post so I understand what you are talking about. I am a little busy now, but I think I can write a script for you tomorrow.
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: how to MOVE or copy folders containing subfolders
Reply #4 - Mar 20th, 2014 at 7:25am
 
Here is an untested script.

Make sure directory F:\AllFiles exists, this is the "target" for the copy.
Make sure directory F:\AllFiles\Logs exists, here the script will write log files.

Save the script below as, for example, C:\Bin\CopyReadyFiles.bat
Create a new WD task using the "Start any bat file" plugin ( http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBat.html ).
Let it monitor directory F:\AllFriends including subdirectories.
On "Events" select "DIRNEW" and (if you can, it is not always available) "DIRREN". Unselect all other events.
On "Filter Events" create a filter so the task will only start for "100%" directories, see the attached picture.




Code:
rem -- settings
SET TARGETDIR=F:\AllFiles
SET LOGFILE=F:\AllFiles\Logs\%WD_DATE%.txt

echo %TIME% START %WD_REASON% %WD_FILE% >> "%LOGFILE%"
IF /i "%WD_REASON%" EQU "DIRNEW" GOTO :NewDirectory
IF /i "%WD_REASON%" EQU "DIRREN" GOTO :NewDirectory

rem some other kind of event, we should just ignore it (better to do this using http://www.watchdirectory.net/wdhelp/help/wdnewconfigpage4.html ).
echo %TIME%     %WD_REASON% is ignored by this script    >> "%LOGFILE%"
GOTO :Done


rem section that processes the "100%" directory, make sure to create a filter
rem on http://www.watchdirectory.net/wdhelp/help/filter_events.html
rem "file title contains 100%"
rem WD_FILE contains the complete path to the new directory, for example
rem F:\AllFriends\Alex\Match Replay\100% of MATCH REPLAY - 3 file of 3 - 500 MB
rem this script copies all files inside "F:\AllFriends\Alex\Match Replay" to the target directory

:NewDirectory

rem WD_FILE  = F:\AllFriends\Alex\Match Replay\100% of MATCH REPLAY - 3 file of 3 - 500 MB
rem WD_DIR   = F:\AllFriends
rem WD_RELDIR= Alex\Match Replay

rem create the correct target directory
echo %TIME%     creating directory %TARGETDIR%\%WD_RELDIR% >> "%LOGFILE%"
MD "%TARGETDIR%\%WD_RELDIR%" >> "%LOGFILE%" 2>&1

rem and copy everything
echo %TIME%     Copying >> "%LOGFILE%"
COPY /B /Y "%WD_DIR%\%WD_RELDIR%\*.*" "%TARGETDIR%\%WD_RELDIR%" >> "%LOGFILE%" 2>&1

GOTO :DONE


:Done
echo %TIME% DONE %WD_REASON% %WD_FILE% >> "%LOGFILE%"
GOTO :EOF
 


Back to top
 

cptfisher.png (36 KB | 169 )
cptfisher.png

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
Page Index Toggle Pages: 1