Batch program for natural to 7-digit file name conversion? (Miscellaneous)
> Dear all,
>
> I need to transfer data between different programs. However, the names
> of the files with the respective data follow different conventions:
> the input uses natural numbers for files names (i.e. 1, 2 ... 999999),
> whereas the target program requires seven-digit file names, with leading
> zeroes (0000001, 0000002 ... 0999999, 1000000) to order them properly.
>
> I wonder whether such conversion could be done with a batch program's
> "FOR %variable IN (set) DO"-loops, or if a more complex command set is
> required. Maybe with a 4DOS's .BTM batch file, or using a script
> language (Perl, Java, Rexx)?
>
> Thanks for input, Torsten
FOR %%i IN (?) DO call move.bat %%i 000000%%i
FOR %%i IN (??) DO call move.bat %%i 00000%%i
...
move.bat:
move /Y srcdir\%1 destdir
ren destdir\%1 %2
**** OR even better ******
FOR %%i IN (?) DO ren %%i 0%%i
FOR %%i IN (??) DO ren %%i 0%%i
FOR %%i IN (???) DO ren %%i 0%%i
FOR %%i IN (????) DO ren %%i 0%%i
FOR %%i IN (?????) DO ren %%i 0%%i
FOR %%i IN (??????) DO ren %%i 0%%i
FOR %%i IN (???????) DO ren %%i 0%%i
*** both methods assume there are only files to be converted in the directory
Complete thread:
- Batch program for natural to 7-digit file name conversion? - Torsten, 09.06.2017, 11:23 (Miscellaneous)
- Batch program for natural to 7-digit file name conversion? - tom, 09.06.2017, 13:02
- Batch program for natural to 7-digit file name conversion? - Torsten, 28.06.2017, 13:29
- Batch program for natural to 7-digit file name conversion? - tom, 09.06.2017, 13:02