|
| |||||||||
| Tags: batch file, file, program |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Batch file to rename a file
I'm not sure where to post this but I hope someone can help. I require a batch file that will normally start a program on a daily basis. However when the system reaches a certain date it must start an alternative program. Basically this is what I need: if %date% is not eqaul to "ddmmyyyy" then goto normal alternative.exe exit normal.exe exit |
|
#2
| ||||
| ||||
| Re: Batch file to rename a file
There are many command line program, one such called is Datedir which is intended mainly for use in batch files. Give it the name of an existing folder, and it will rename that folder with an integer representing the current date. Alternatively, with no parameters, the command "datedir" will create a new folder named for the current date. Or you can write a simple batch file to start a program when you start your computer:
|
|
#3
| |||
| |||
| Re: Batch file to rename a file
Thanks James but I'm not sure if that's exactly what I require. Lets say I have a batch file that looks like this: @echo off cls echo Today is %date% If %date% is not equal to "ddmmyyy" the goto start :alternative rename xyz.dbf 123.dbf goto exit :start strtprog.exe :exit But I need to know the correct syntax of the If %date% is not equals |
|
#4
| ||||
| ||||
| Re: Batch file to rename a file
You can rename a file and add a date stamp like this: ren h:\test\hello.txt hello%date%.txt If you want to add date stamp to all files in a folder, you can use this: h: cd test for %%i in (*.*) do ren %%i %%i-%date%.txt You can paste either of the source codes into notepad and save the file as xxx.cmd or xxx.bat |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Batch file to rename a file" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Learning Batch file to open a program or a file | Ikshana | Windows Software | 3 | 04-04-2011 08:24 PM |
| Windows Batch file to output directory names and size to txt file | m2thearkus | Software Development | 6 | 16-07-2010 01:04 AM |
| Dos batch file to sort files based on file names. | Jon Osborn | Windows Server Help | 9 | 17-06-2009 12:06 PM |
| Batch file to copy a file from the local drive to a computer on lan? | dudelearn | Tips & Tweaks | 3 | 12-03-2009 01:56 PM |
| Rinominare File con data attraverso un file Batch | Daytan | Windows Server Help | 1 | 19-09-2007 12:10 AM |