Solved Need to auto incriment filename when saving.

September 13, 2011 at 00:21:03
Specs: Windows 7
Good day,

I hope you guys are able to help me with this.

My script is as follows:

@echo off
setLocal EnableDelayedExpansion

cd C:\Decryptor
for /f "tokens=* delims= " %%a in (c:\temp\recordings.txt) do (encryptwave-w32r-1-1.exe -d "%%a" -o "C:\recordings\recording.wav")


What i need is for the file name to change each time it saves a new decripted recording.
right now it is just overwriting the recording.wav each time.

I need it to incirment as follows:

recording1.wav
recording2.wav
recording3.wav
recording4.wav
...


How can i do this?

any help will be appreciated.


See More: Need to auto incriment filename when saving.

Report •


#1
September 13, 2011 at 03:09:58
✔ Best Answer
@echo off
setLocal EnableDelayedExpansion

cd C:\Decryptor
set N=1
for /F "delims=" %%a in (C:\temp\recordings.txt) do (
  encryptwave-w32r-1-1.exe -d "%%a" -o "C:\recordings\recording!N!.wav"
  set /A N+=1
)


Report •

#2
September 13, 2011 at 04:13:25
Works like a charm.
Thank you Ivo.

One more Question.

If I wanted to name the files as the original file name in the path in recordings.txt file.
How can i do this?

Like if the path is:

\\172.16.2.16\Recordings\201104\1405\40\1001410939_1001410938_e517a5b41d1cc82f70b7ede7.i3r


to name that recording: 1001410939_1001410938_e517a5b41d1cc82f70b7ede7.wav
instead of recording1.wav

Would this be possible?


Report •

#3
September 13, 2011 at 07:18:49
Thank you for the feedback. Here what you wish.

@echo off & setLocal EnableDelayedExpansion

cd C:\Decryptor
for /F "delims=" %%a in (C:\temp\recordings.txt) do (
  set name=%%a
  call :NAME !name!
  set name=!name:~0,-4!
  encryptwave-w32r-1-1.exe -d "%%a" -o "C:\recordings\!name!.wav"
)
goto :EOF

:NAME
  for /F "tokens=1* delims=\" %%i in ("!name!") do (
    if "%%j"=="" (goto :EOF) else (set name=%%j)
)
goto :NAME


Report •

Related Solutions

#4
September 13, 2011 at 07:44:44
Thanks it works perfectly.

very awesome.

Thank you so much.


Report •

#5
September 13, 2011 at 07:57:41
One last question:

In my recordings.txt file after i ran my SQL query I get 10 results.

\\172.16.2.16\Recordings\201106\2406\10\2001341307_2001341304_216e1874fa49adc5ff56628e.i3r
\\172.16.2.16\Recordings\201106\2411\10\2001349131_2001349119_11e2ca75d6998d6d91d61caf.i3r
\\172.16.2.16\Recordings\201106\2107\40\2001283108_2001283086_955b2c7ec32816dfcf3bf649.i3r
\\172.16.2.16\Recordings\201106\2313\30\2001337291_2001337286_095c4e35aa6e2fcbc2a9226e.i3r
\\172.16.2.16\Recordings\201106\2411\00\2001348989_2001348979_9fe4bc43b39a4be27b0556ab.i3r
\\172.16.2.16\Recordings\201106\2406\10\2001341264_2001341260_a753af75ffafaa5a41a1c82a.i3r
\\172.16.2.16\Recordings\201106\2409\20\2001346375_2001346362_da7ea3e79c2286692e50ee28.i3r
\\172.16.2.16\Recordings\201106\2409\20\2001346387_2001346383_756ae2a6d00852814669120b.i3r
\\172.16.2.16\Recordings\201106\2411\40\2001349889_2001349880_539f57beacdd0a69451dd2ec.i3r
\\172.16.2.16\Recordings\201106\2212\50\2001320982_2001320973_0919b3d6ff369c294ee22488.i3r

However after the bat script converts all the files to .wav format, there is only 9 .wav files instead of 10.

I have tested this with diffrent queries and each time the first line in the recordings.txt file is not converted to .wav.
almost like the first line is being skipped.

What could cause this?


Report •

#6
September 13, 2011 at 08:52:26
I carefully examined and tested my script using the list you posted and the result always was fine: 10 lines in give 10 lines out. The one thing I can suppose is encryptwave fails to do its job with the first file for reasons unknown to me.
Maybe that file is not accesible as hidden or protected; obviously I can test lines-in/lines-out but not the full process.

Anyway I confirm the script handles correctly all records it reads as input, no skip at all.


Report •

#7
September 13, 2011 at 21:33:10
Thank you so much for your help and your time Ivo.
it is much appreciated.


Report •


Ask Question