• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

help with simple batch file

djmonson

New Member
Joined
Jun 17, 2007
Messages
15 (0.00/day)
i want to create a batch file that will:
move files from 'directory1' to 'directory2'
if (and only if) the file DOES NOT begin with an underscore

anyone know how to do this??

David
 
umm..? what are you trying to do? copy directories? basic is a good language for things like this. IF/THEN statements rule. :D
 
umm..? what are you trying to do? copy directories? basic is a good language for things like this. IF/THEN statements rule. :D

yes, but batch files are easier to create within dos, and i think that's what he's trying to do.
 
sorry if i wasn't specific enough. and i don't need it to be a batch file necessarily.

i want an automated way to move files from one folder to another (both on the C drive)
but i want it to move all mp3 files EXCEPT for the ones that begin with an underscore
 
i've found that the easiest way to copy things is to do an advanced search and type in *.mp3 and then just choose whatever files you want, easiest by sorting by name, then copy..
 
can't that be made into an automated process? i do the action you recommended many times over, and i was hoping that somehow i could create a file that, when double-clicked, would just move the files from that location to another (but not if they start with an underscore, like i mentioned)
 
So basically you want to move finished downloads to some other folder and temp files start with an underscore? Just a guess.
 
copy and paste this into notepad, and save as .bat



example:

@echo off
xcopy /c /d /f /k /s /y "c:\my music" e:\music



just replace it with the correct locations.

and when you run the batch file it will ask you if you want to copy the the file, or the directory. just type "D" for directory and your good to go.
 
Last edited:
does the "/c /d /f /k /s /y" section act like an "if statement"? or what is that code for?
 
xcopy is DOS.
its xcopy commands...

/c = Continues copying even if errors occur.
/d = Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.
/f = Displays full source and destination file names while copying.
/k = Copies attributes. Normal Xcopy will reset read-only attributes.
/s = Copies directories and subdirectories except empty ones.
/y = Suppresses prompting to confirm you want to overwrite an existing destination file.


its easy and simple. i use it all the time to back up all the stuff on my hard drive to my external.
 
did this help you out?bump.
 
no problem, enjoy.
 
Back
Top