| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 93148 | 2008-09-05 04:41:00 | Batch file problems | ubergeek85 (131) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 702719 | 2008-09-05 04:41:00 | Hi guys. For some reason a demo batch file I made isn't working. All it's supposed to do is create some folders (one with a variable as a name), and copy a bunch of different file types to the folder with the variable as a name. @echo off : backup.bat cd.. cd.. cd.. cd.. cd.. cd.. cd.. cd.. cd.. echo At root directory : This is to make sure we are in the root directory. mkdir Backups echo Made Backups folder : Makes the directory. It assumes that there isn't one already called that. : It's really designed to round up all elegibile files into a directory, for copying onto a CD or similar medium. cd Backups set folder=%date:~10,4%_%date:~4,2%_%date:~7,2% : Sets the folder variable, uses US date format, MM/DD/YYYY mkdir %folder% echo Made dated folder, date used is %folder% cd.. copy *.txt c:\Backups\%folder\ : Text files copy *.jpg c:\Backups\%folder\ copy *.gif c:\Backups\%folder\ copy *.jpeg c:\Backups\%folder\ copy *.jpe c:\Backups\%folder\ copy *.bmp c:\Backups\%folder\ : Images copy *.doc c:\Backups\%folder\ copy *.docx c:\Backups\%folder\ copy *.xls c:\Backups\%folder\ copy *.xlsx c:\Backups\%folder\ copy *.mdb c:\Backups\%folder\ copy *.accdb c:\Backups\%folder\ copy *.pub c:\Backups\%folder\ copy *.ppt c:\Backups\%folder\ copy *.pptx c:\Backups\%folder\ : Most Microsoft Office files echo Copied files : End And it gives this: C:\Documents and Settings\student\Desktop>backup At root directory A subdirectory or file Backups already exists. Made Backups folder A subdirectory or file 2008_09_05 already exists. Made dated folder, date used is 2008_09_05 Copy of New Wordpad Document.txt The system cannot find the path specified. 0 file(s) copied. Copy of New Wordpad Document.jpg The system cannot find the path specified. 0 file(s) copied. Copy of New Wordpad Document.gif The system cannot find the path specified. 0 file(s) copied. *.jpeg The system cannot find the file specified. 0 file(s) copied. *.jpe The system cannot find the file specified. 0 file(s) copied. *.bmp The system cannot find the file specified. 0 file(s) copied. New Wordpad Document.doc The system cannot find the path specified. 0 file(s) copied. *.docx The system cannot find the file specified. 0 file(s) copied. *.xls The system cannot find the file specified. 0 file(s) copied. *.xlsx The system cannot find the file specified. 0 file(s) copied. *.mdb The system cannot find the file specified. 0 file(s) copied. *.accdb The system cannot find the file specified. 0 file(s) copied. *.pub The system cannot find the file specified. 0 file(s) copied. *.ppt The system cannot find the file specified. 0 file(s) copied. *.pptx The system cannot find the file specified. 0 file(s) copied. Copied files C:\> For some reason no files are copied to %folder%. Any idea why? Thanks. |
ubergeek85 (131) | ||
| 702720 | 2008-09-05 05:16:00 | Not sure geekster. I use this to backup my outlook.pst file. The bat file is on D: and when run it copies and overwrites the destination whenever I run it as I want it to do. Works great for me if C ever crashes. Schedule runs it every couple of days. Outlook has to be closed at the time it runs. copy "C:\Documents and Settings\PC1\Application Data\Microsoft\Outlook\Outlook.pst" E:\Outlook2003Backup.pst |
Bantu (52) | ||
| 702721 | 2008-09-05 05:23:00 | Your copy commands havea typo: ...%folder\ instead of %folder% |
dyewitness (9398) | ||
| 702722 | 2008-09-06 07:03:00 | A little tip ... It's more efficient and guaranteed to get to the root folder no matter how many directories deep you are using this: "CD \" rather than a series of "CD .." |
Rod J (451) | ||
| 702723 | 2008-09-06 08:42:00 | You need to use some code like this: IF EXIST DirectoryName GOTO end md directoryName :end |
johnd (85) | ||
| 702724 | 2008-09-08 00:18:00 | Your copy commands havea typo: ...%folder\ instead of %folder% That did it. Thanks. |
ubergeek85 (131) | ||
| 1 | |||||