Solved Struggling with copy, for & variables

November 12, 2012 at 21:02:45
Specs: Windows 7 Home Premium x64, DualCore 2.10GHz/4GB
OK I've got a batch script that renames my files to 1.mp3, 2.mp3, 3.mp3 & stores the original names in a text file for renaming later. Thats step1 :D

I also have a batch file to rename the files back to there original names (step3).

I'm having issues with step2

I'd like to be able to use a for command to run through the renamed mp3's i.e. 1.mp3, 2.mp3 etc (which is why I numbered them) and DO a copy /b /y 1.mp3 + %DATE% + %TIME% 1.mp3 (replacing the 1's with each iteration of the loop OR a SET variable.

I have tried "!J!.mp3 + %anything%" "!J!.mp3" & all kinds of different configurations (i.e. with & without ""!! & more) & am getting nowhere.

I am relatively new to scripting & have been able to find many useful tips all over, unfortunately my knowledge is limited & I'm obviously failing to understand the "examples" I've seen as I'm unable to get it working after 6 days of non stop searching trying & scratching my head I thought it time to ask lol.

Thanks in advance for any help/advice.


See More: Struggling with copy, for & variables

Report •

✔ Best Answer
November 13, 2012 at 08:13:17
If you're trying to append the date and time to the mp3 files content, you need to either use echo, or create a text file containing %date% %time%.
to use echo:
for /L %%a in (1,1,3) do echo %date% %time%>>%%a.mp3

if you want to use copy:
>temp echo %date% %time%
for /L %%a in (1,1,3) do copy /b %%a.mp3 + temp %%a.mp3

or, if you wanted to skip the renaming part:
for %%a in (*.mp3) do echo %date% %time%>>%%a



#1
November 12, 2012 at 23:49:26
copy one+two three

Combines FILES not vars or strings.


====================================
Life is too important to be taken seriously.

M2


Report •

#2
November 12, 2012 at 23:51:55
Not trying to combine the mp3's trying to embed them with DATE & TIME, but thanks anyway.

Report •

#3
November 12, 2012 at 23:55:39
First see if your DATE & TIME vars are legal for file names.

No slash, colon etc.


====================================
Life is too important to be taken seriously.

M2


Report •

Related Solutions

#4
November 13, 2012 at 00:00:45
I'm using the in built Environment variables %DATE% %TIME% & it works for *.mp3 + %DATE% %TIME% *.mp3.

What I want to know is how to cycle through the MP3's i.e. 1.mp3 then 2.mp3 then 3.mp3 etc...


Report •

#5
November 13, 2012 at 00:58:07
Someone may fix your script if you post it.


====================================
Life is too important to be taken seriously.

M2


Report •

#6
November 13, 2012 at 08:13:17
✔ Best Answer
If you're trying to append the date and time to the mp3 files content, you need to either use echo, or create a text file containing %date% %time%.
to use echo:
for /L %%a in (1,1,3) do echo %date% %time%>>%%a.mp3

if you want to use copy:
>temp echo %date% %time%
for /L %%a in (1,1,3) do copy /b %%a.mp3 + temp %%a.mp3

or, if you wanted to skip the renaming part:
for %%a in (*.mp3) do echo %date% %time%>>%%a


Report •

#7
November 13, 2012 at 14:11:18
All 3 options worked nbrane :D but I've plumped for the 3rd option as it saves me numbering & renaming the files which leaves the code much more efficient.

Thank you so much for this you don't know how much help you have been, as well as solving my problem I now also understand the for & variables in batch files.

I think I was focusing too much on the copy command because I had been using it as a one line one file solution for so long, again thank you


Report •

Ask Question