Good day,
guys need your help,
need anyone who has idea on my scenario
currently need a batch file to move folders using robocopy
scenario:
i need to move a folder including all subfolders inside it
sample:
C:\sourcefolder\upload\102910\folder1
C:\sourcefolder\upload\102910\folder2
C:\sourcefolder\upload\102910\folder3
to
D:\destinationfolder\processed\102910\folder1 etc.
the catch here, the folder 102910 is not a constant name, everyday it will change today date.
so we can't put a constant address i have to used a wildcard, i already solve this problem.
my problem facing now, when during moving, i can't move the folders only the files are being move.
so sample:
c:\sourcefolder\upload\102910\folder1
C:\sourcefolder\upload\102910\folder2
C:\sourcefolder\upload\102910\folder3
C:\sourcefolder\upload\102910\sample.txt
C:\sourcefolder\upload\102910\helo.doc
only the sample.txt and helo.doc are being move. the folders are not being move.
you may suggest using dos move function the problem about the dos move function,
inside the upload folder there are other folders that i don't need to move.
as below code you may see i used a IF EXIST where it will look each folder if there is a .txt file, if it has no .txt file it will not move...only those folders that has .txt file are being move.
here is my syntax:
echo off
SET DRIVELETTER=c:\sourcefolder\upload
SET DESTINATION_PROCESSED=d:\destinationfolder\process ed\%%~nxz
FOR /D %%z IN ( "%DRIVELETTER%\*.*" ) DO (
ECHO path:%%~z
ECHO name:%%~nz
rem MOVE FILES AND FOLDERS TO NEW LOCATION
IF EXIST %%~fz\*.TXT ROBOCOPY "%%z" "%DESTINATION_PROCESSED%" "*.*" /XD D:\test\upload\otherfolder /MOVE /R:10 /W:30 /Z )
)
hopefully someone can help me on this.
Thank you.