| 1. |
Solve : Batch file to Delete Dates from pdf files? |
|
Answer» Hi All, I would have thought we have given you enough teaching already on string replacement to do this yourself. You tell him, Squashman! Quote from: Squashman on January 12, 2012, 03:31:57 PM You can't rename the file to the name of a file that already exists. So what are we to do with the 2nd file? Very true, within the same folder. If, perhaps, this is going to go through different folders, it's possible to have same names in different folders. But as mentioned, again, we require more information in order to give you the best possible answer. Quote from: Squashman on January 12, 2012, 03:31:57 PM have the same name. You can't rename the file to the name of a file that already exists. So what are we to do with the 2nd file? The second file is in a different folder. I would try and be explicit now. I do have a code which I run in different folders to prefix pdf files with dates. I have this script in each folder so folder 12 it will prefix the files with date 20120101 echo off pushd C:\Aug\12 ::for /f "tokens=*" %%a in ('dir /b /a-d') for %%a in (*) do rename "%%a" "20120101 %%a" popd this will result in the following for example 20120101 ACA 811 DDR63 03-01-2012.pdf 20120101 TULIPA-2_DDR_85_030112.pdf 20120101 BAT-109 DDR 01-Jan-12.pdf I would like to add to the above code so the dates are removed. Apologies Squashman, the dates aren't constant and are in the formats seen above. I would like to then archieve the result below within each folder; 20120101 ACA 811 DDR6.pdf 20120101 TULIPA-2_DDR_85.pdf 20120101 BAT-109 DDR .pdf I hope this is clear now...... Many Thanks........I thought Raven gave you a batch file for removing the end date and prefixing a new date at the beginning of the file already.Because of the inconsistent dates, and the inconsistencies in the names, it's really not possible to do this WITHOUT some sort of manual oversight. See this POST for the rename program that I built a little while ago. It will allow you to crop out what you want to keep from the old file name and will add a standard beginning name, if you want, or, at the very least, allow you to have a standard naming convention that we can then do a much simpler code to in order to get everything to work out how you want it to work out. Try the program on a test directory a few times first so that you can see what the feel of it is, and then when you are comfortable with it, run it on the directory you want to run it on. You could probably use it to get the standard beginning you are looking for depending on the folder if you set up a .txt file named "targetdirectory.txt" and place it in the same folder as the program with the target folder you are wanting to affect in there.I THINK by now, 50 files could have been renamed by hand. |
|