AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
![]() ![]() Set "name=!name!_!date:~6,4!!date:~3,2!!date:~0,2!!ending!"ĮDIT: After testing around a bit I figured, that subfolders are included as well! I put extra code to both codes marked with REM and two extra spaces. If not !chkname!=!name! ( echo depth to small Weeeeell First of all thanks again to Fabre and for their patience with me :)Īfter the hint with the second batch file I had to test a few things as not everything worked as fine, but now everything works great! (just uncomment the ren line to get the job done) my test directory contains 2 text files and 1 other file.paths.txt contains just a line C:\full\path\to\test\*.txt.If not !chkname!=!name! ( echo please increase DEPTH value Rem but we can check if it is really a basename We cannot break the inner loop orįor /L %%I in (1,1,?PTH%) do set name=!name:*\=! Copying then deleting a large file can take a long time. Last minor one: use rename instead of copy plus delete. See the xcopy command for further information about this command. wav, while keeping the original files and extensions. wav Using a wildcard lets you rename all files with. The other problem is the for /R loop: after pushd, the argument needs to be. Rename a file extension keeping the original Use the following command at the MS-DOS or Windows command line or within a batch file. I replaced that by a basename computation instead: set name=!name:*\=! done enough times (not very subtle but hey batch files forces us to do such things) which preserves the wildcard Even if name is *.txt it will return bar.txt. Ok, I figured out 2 problems and now it works Now the question: Why does this happen and how do I get rid of it? Or do I just use the wrong type of wildcards?Īgain: This is my first time I work with batch, so it might be something simple ) But that seems to be working if I do not use wildcards. I know that a lot of it is probably easier and more efficient to do, but this is my first batch project and I am quiet happy except for the wildcard problem.īecause name is set to the Path at the start of the first FOR-Loop. I got it to work on my PC quiet well but as I gave it to testing they asked to make the use of wildcards Z:\Path\*.* possible.įor /F "tokens=*" %%m in (paths.txt) do ( paths.txt) and when you start the program, it should take any line (=path->file) from there and rename it. Recently I started working and my first task is to write a batch file that automatically changes filenames to filename_date with the original file-ending.įor that you should be able to write paths into a textfile (e.g. ![]()
0 Comments
Read More
Leave a Reply. |