Solved

.bat to backup certain file adding date and sequence # to end of the file name.

Posted on 2013-05-13
1
323 Views
Last Modified: 2013-06-12
I used to know how to do this, I even wrote them and used them on jobs. I had a couple of handy DOS batch file books once upon a time..

Help save me some time (and if you could also give me a link to a good online batch command resource I'd appreciate it).

I want a batch file to backup this file:

C:\Documents and Settings\Myname\Application Data\Mozilla\Firefox\Profiles\q4lyst7r.default\sessionstore.js

and place it into the folder c:\firefoxback\

I want to name the backups by date and sequentially such as:
sessionstore2013.05.11.01.js
sessionstore2013.05.11.02.js

The current  yyyy.mm.dd.## could be stored in a .txt/.lst file for easy determination of the next name or could be determined by looking at existing file names.
0
Comment
Question by:Missus Miss_Sellaneus
1 Comment
 
LVL 14

Accepted Solution

by:
Giovanni Heward earned 500 total points
ID: 39163144
This should get you started...

@echo off
setlocal enabledelayedexpansion
set mm=%date:~4,2%
set dd=%date:~7,2%
set yyyy=%date:~10,4%
set yy=%date:~12,2%
set source=%userprofile%\Application Data\Mozilla\Firefox\Profiles\q4lyst7r.default\sessionstore.js
set dest=c:\firefoxback
if exist "!source!" (
	for /l %%c in (1,1,8) do (
		set /a check=%%c+1
		if exist "!dest!\sessionstore!yyyy!.!mm!.!dd!.0%%c.js" (
			if not exist "!dest!\sessionstore!yyyy!.!mm!.!dd!.0!check!.js" (
				copy "!source!" "!dest!\sessionstore!yyyy!.!mm!.!dd!.0!check!.js"
				goto :eof
			)
		) else (
			copy "!source!" "!dest!\sessionstore!yyyy!.!mm!.!dd!.0%%c.js"
			goto :eof
		)
	)
)

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now