Batch script to search for variable/move files
Moderator: DosItHelp
-
- Posts: 1
- Joined: 12 Dec 2012 11:51
Batch script to search for variable/move files
So iv'e had no luck trying to figure this out. Im trying to make a batch script to search for variable in file names (ex. HDTV) in one folder if file name contain the word then move to specific location on different hard drive.
Re: Batch script to search for variable/move files
boostudiosgd wrote:So iv'e had no luck trying to figure this out. Im trying to make a batch script to search for variable in file names (ex. HDTV) in one folder if file name contain the word then move to specific location on different hard drive.
This searches all files in the current folder for HDTV (case sensitive) and moves those files to another drive.
Makes sure that the target folder exists first.
Code: Select all
@echo off
for /f "delims=:" %%a in ( ' findstr "HDTV" *.* ' ) do move "%%a" "d:\location\ on another drive\"
-
- Posts: 20
- Joined: 21 Dec 2012 13:36
- Location: United States
Re: Batch script to search for variable/move files
If you are using Vista+ or Resource Pack on XP, use RoboCopy, else use xcopy and del.
See RoboCopy /? for help.
See xcopy /? for help.
To use a batch variable replace the HDTV term with the variable's value.
Code: Select all
RoboCopy . "D:\Location\on another drive\" *HDTV* /MOV
See RoboCopy /? for help.
Code: Select all
xcopy *HDTV* "D:\Location\on another drive\" /I /Y
del *HDTV* /Q
See xcopy /? for help.
To use a batch variable replace the HDTV term with the variable's value.
Re: Batch script to search for variable/move files
My mistake. I thought the task was to move files that *contain* HDTV.