Batch script to copy 0 byte and non 0 byte to another dir
Moderator: DosItHelp
Batch script to copy 0 byte and non 0 byte to another dir
I tried to find the solution but no luck.Could some one please provide me the batch script for the below one.
In a directory i had 3 types of files which need to move to another directory.
1) .RAW and .XML files if they are zero they need to move
2) Any file without any extension i.e normal file need to me moved whether it is zero or non zero.
Thanks in advance.
In a directory i had 3 types of files which need to move to another directory.
1) .RAW and .XML files if they are zero they need to move
2) Any file without any extension i.e normal file need to me moved whether it is zero or non zero.
Thanks in advance.
Re: Batch script to copy 0 byte and non 0 byte to another di
Code: Select all
@echo off
set "from=D:\Test 2"
set "to=D:\Test 1"
set masks_1=*.RAW *.XML
set masks_2=*.
pushd "%from%"
for /f "tokens=1*" %%i in ('robocopy . %random% %masks_1% /nc /ndl /njh /njs /l') do if %%i==0 >nul move /y "%%j" "%to%"
for /f "delims=" %%i in ('dir /a-d/b %masks_2%') do>nul move /y "%%i" "%to%"
popd
exit /b 0
Re: Batch script to copy 0 byte and non 0 byte to another di
Hi Yuri,
Thanks a lot for your script.I had one question if the file is `text1` i.e without any extension.Not sure the below intilisation will work or not.Please explain me on this concept to move the file to different directoty.
Thanks a lot for your script.I had one question if the file is `text1` i.e without any extension.Not sure the below intilisation will work or not.Please explain me on this concept to move the file to different directoty.
set masks_2=*.
Re: Batch script to copy 0 byte and non 0 byte to another di
Hi Yuri,
Thanks a lot for your reply.I had some queries please explain me.I didn't understand the below one.For example i had file names 'file1,file2 etc which are zero or non zero'.Could you please explain me how the below intilisation will work.
Thanks a lot for your reply.I had some queries please explain me.I didn't understand the below one.For example i had file names 'file1,file2 etc which are zero or non zero'.Could you please explain me how the below intilisation will work.
Code: Select all
set masks_2=*.
Re: Batch script to copy 0 byte and non 0 byte to another di
bhas85 wrote:I had one question if the file is `text1` i.e without any extension.Not sure the below intilisation will work or not.
You can try the script in a test folder. What happened to the files in the folder when you ran this?
Re: Batch script to copy 0 byte and non 0 byte to another di
Hi Foxidrive,
When i tried to test the script.It says file not found.
o/p
Please let me know what's wrong here.I need to move all file type as file to "TO" Folder as well.
When i tried to test the script.It says file not found.
@echo off
set "from=U:\vijay1"
set "to=U:\vijay2"
set masks_1=*.raw *.xml
set masks_2=*.
pushd "%from%"
for /f "tokens=1*" %%i in ('robocopy . %random% %masks_1% /nc /ndl /njh /njs /l') do if %%i==0 >nul move /y "%%j" "%to%"
for /f "delims=" %%i in ('dir /a-d/b %masks_2%') do>nul move /y "%%i" "%to%"
popd
pause
o/p
Code: Select all
'\\cifs.flnas.info53.com\home'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
File Not Found
Press any key to continue . . .
Please let me know what's wrong here.I need to move all file type as file to "TO" Folder as well.
Re: Batch script to copy 0 byte and non 0 byte to another di
Is U:\ a network drive?
If it is you have to map it sometimes.
If it is you have to map it sometimes.
Code: Select all
net use U: \\
REM ^<^<^< Your drives network computer name should be put after the \\
Re: Batch script to copy 0 byte and non 0 byte to another di
Hi Joesphf,
I changed the drive but still i am seeing file not found error.Could you please help me what exactly do i need to change.
error:
I changed the drive but still i am seeing file not found error.Could you please help me what exactly do i need to change.
Code: Select all
@echo off
set "from=C:\batch\vijay1"
set "to=C:\batch\vijay2"
set masks_1=*.raw *.xml
set masks_2=*.
pushd "%from%"
for /f "tokens=1*" %%i in ('robocopy . %random% %masks_1% /nc /ndl /njh /njs /l') do if %%i==0 >nul move /y "%%j" "%to%"
for /f "delims=" %%i in ('dir /a-d/b %masks_2%') do>nul move /y "%%i" "%to%"
popd
pause
error:
Code: Select all
File Not Found
Press any key to continue . . .
Re: Batch script to copy 0 byte and non 0 byte to another di
You are positive you have files in this directory: C:\batch\vijay1
Re: Batch script to copy 0 byte and non 0 byte to another di
The File Not Found error is coming from the DIR command in this line of code.
Basically means you do not have any files without an extension.
Code: Select all
for /f "delims=" %%i in ('dir /a-d/b %masks_2%') do>nul move /y "%%i" "%to%"
Basically means you do not have any files without an extension.
Re: Batch script to copy 0 byte and non 0 byte to another di
Hi Squashman,
Yes i had files in the directory "C:\batch\vijay1".But still i am getting file not found.
1.raw
1.xml
kiran.xml
vijay.raw
vijay123
Yes i had files in the directory "C:\batch\vijay1".But still i am getting file not found.
1.raw
1.xml
kiran.xml
vijay.raw
vijay123