Friday, December 16, 2011

Sometimes, you need to use an image with a filename which contains more than one dots: "a.png_processed.png"

However, the LaTeX will have problem with that, and you need to replace the internal dots with another character, for example, '_'.

The following code will do this automatically for you. Create a batch file: "convert_dots_to_underline.bat"
and type the following code there:

ls *.png > png_files.txt
FOR /F "tokens=1,2,3 delims=." %%A IN (png_files.txt) DO ren %%A.%%B.png %%A_%%B.png
FOR /F "tokens=1,2,3,4 delims=." %%A IN (png_files.txt) DO ren %%A.%%B.%%C.png %%A_%%B_%%C.png
FOR /F "tokens=1,2,3,4,5 delims=." %%A IN (png_files.txt) DO ren %%A.%%B.%%C.%%D.png %%A_%%B_%%C_%%D.png

Execute the batch file in the folder of image files, and their filename will be corrected. It will correct filenames up to 3 internal dots.

No comments:

Post a Comment