Need immediate help with a batch script
Moderator: DosItHelp
Need immediate help with a batch script
I am new to batch script.. Requirement is like this..
> Read the file content (it has list of file names)
> find all those files from above step in a folder A
> then move those files to folder B
Kindly please help on how I can do this using batch script.
> Read the file content (it has list of file names)
> find all those files from above step in a folder A
> then move those files to folder B
Kindly please help on how I can do this using batch script.
Re: Need immediate help with a batch script
If you need immediately help, Google is your friend!
What do you tried?
What do you tried?
Re: Need immediate help with a batch script
http://ss64.com/nt/for_f.html
http://ss64.com/nt/dir.html
http://ss64.com/nt/move.html
http://ss64.com/nt/dir.html
http://ss64.com/nt/move.html
Re: Need immediate help with a batch script
Thx squashman. Trying to understand and prepare a script but not sure how far I will go.
Is there anyone who can write up in batch script format.
Is there anyone who can write up in batch script format.
Re: Need immediate help with a batch script
untested
Code: Select all
@echo off
FOR /F "usebackq delims=" %%G in ("filelist.txt") do (
IF EXIST "C:\Folder A\%%G" MOVE "C:\Folder A\%%G" "C:\Folder B\%%G"
)
Re: Need immediate help with a batch script
Squashman, No it din't work
I have modified like this and tried but it didn't do anything
I had one file in raj1 folder and listed that file name in filelist.txt. Created raj2 folder and ran the script but failed.
@echo off
FOR /F "usebackq delims=" %%G in ("filelist.txt") do (
IF EXIST "C:\raj1 A\%%G" MOVE "C:\raj1 A\%%G" "C:\raj2 B\%%G"
)
I have modified like this and tried but it didn't do anything
I had one file in raj1 folder and listed that file name in filelist.txt. Created raj2 folder and ran the script but failed.
@echo off
FOR /F "usebackq delims=" %%G in ("filelist.txt") do (
IF EXIST "C:\raj1 A\%%G" MOVE "C:\raj1 A\%%G" "C:\raj2 B\%%G"
)
Re: Need immediate help with a batch script
looks like it's looking for some sort of command to read the content of filelist.txt.
Re: Need immediate help with a batch script
If there is an error message you need to post the exact error message you are seeing.
Re: Need immediate help with a batch script
No error on the screen but it's not doing anything either.
Re: Need immediate help with a batch script
Can I see an example of the contents of your File List.
Re: Need immediate help with a batch script
these are the files that's in raj1 folder and same I have listed in filelist.txt. I also putting backslash in front of raj1 and raj2 but it didn't help.
*filelist.txt
RajnishBharti9YSS9G84ML64622.pdf
role.txt
sizing.rtf
*raj1 folder has above three physical files
* raj2 folder is empty
* script.bat looks like this now
@echo off
FOR /F "usebackq delims=" %%G IN ("C:\Users\rbharti\Desktop\archival\filelist.txt") do (
IF EXIST "C:\Users\rbharti\Desktop\archival\raj1\ A\%%G"
move "C:\Users\rbharti\Desktop\archival\raj1\ A\%%G", "C:\Users\rbharti\Desktop\archival\raj2\ B\%%G"
)
*filelist.txt
RajnishBharti9YSS9G84ML64622.pdf
role.txt
sizing.rtf
*raj1 folder has above three physical files
* raj2 folder is empty
* script.bat looks like this now
@echo off
FOR /F "usebackq delims=" %%G IN ("C:\Users\rbharti\Desktop\archival\filelist.txt") do (
IF EXIST "C:\Users\rbharti\Desktop\archival\raj1\ A\%%G"
move "C:\Users\rbharti\Desktop\archival\raj1\ A\%%G", "C:\Users\rbharti\Desktop\archival\raj2\ B\%%G"
)
Re: Need immediate help with a batch script
1) That whole IF EXIST statement needs to be on one line. If it is not on one line then you need to use parenthesis to continue the code block.
2) You have a comma in the middle of the move statement. Why?
3) Is that how your directory structure is? You have a space before your Folder A and Folder B.
2) You have a comma in the middle of the move statement. Why?
3) Is that how your directory structure is? You have a space before your Folder A and Folder B.
Code: Select all
@echo off
FOR /F "usebackq delims=" %%G IN ("C:\Users\rbharti\Desktop\archival\filelist.txt") do (
IF EXIST "C:\Users\rbharti\Desktop\archival\raj1\ A\%%G" move "C:\Users\rbharti\Desktop\archival\raj1\ A\%%G" "C:\Users\rbharti\Desktop\archival\raj2\ B\%%G"
)