Go Back   TechArena Community > Software > Tips & Tweaks
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links



Batch file to rename a file

Tips & Tweaks


Reply
 
Thread Tools Search this Thread
  #1  
Old 02-09-2010
Member
 
Join Date: Sep 2010
Posts: 2
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
Reply With Quote
  #2  
Old 02-09-2010
JAMES_911's Avatar
Member
 
Join Date: Dec 2007
Posts: 1,553
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:
  1. Open notepad. It is located at Start Menu>All Programs>Accessories>Notepad (Windows XP)
  2. Then type start frontpg.exe
  3. Choose File from the menu above. Then choose Save As
  4. Navigate to save on the desktop and type the file name in with .bat filename extension. I have called mine startup.bat
  5. Now you can double click on it on the desktop to test if it opens FrontPage
Reply With Quote
  #3  
Old 02-09-2010
Member
 
Join Date: Sep 2010
Posts: 2
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
Reply With Quote
  #4  
Old 02-09-2010
SUpER CoP's Avatar
Member
 
Join Date: Dec 2007
Posts: 937
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
Reply With Quote
Reply

  TechArena Community > Software > Tips & Tweaks


Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 07:15 AM.