Have you used publish in AutoCAD to create single sheet PDF? AutoCAD will create the file name automatically.
AutoCAD will publish the PDFs by using the layout name. The only option you have is to add file name as prefix. There is no option to create PDFs using file name only.
Now what if you want to have multiple PDF files that use file name? You can’t.
What you can do is to publish them with format file name and layout name, then rename them. Hai Le shares how this can be done quickly and easily. You can use MS-DOS command “rename” using wildcards.
It has limitation, but if your PDF file name follow a pattern like image above, then you can use this method.
This is not really an AutoCAD tips. We will use command prompt and don’t touch AutoCAD at all.
Working with command prompt
Many people today don’t work with command prompt anymore. So let’s start with some introduction.
To open command prompt
To open command prompt, hold win key + R. Win key is the one on your keyboard with Windows logo.
This will open run window. Type CMD then press enter.
Now you have command prompt window open. In this window, you can type old school MS-DOS commands like copy, delete or rename.
To navigate to files folder
First thing you need to do is to change the active folder to your PDF location.
You can use CD to change folder (CD stands for change directory. Before Windows, we call it directory instead of folder).
If I want to open c:\data then I can use cd c:\data. You can see the prompt changed to new active folder.
Understanding the wildcards
Before we start to rename the files, let’s try to understand about wildcards first. You need to understand the file name pattern before you can rename your files.
The command to rename file is
rename ORIGINALNAME NEWNAME
Rename A.PDF B.PDF will rename file A.PDF to B.PDF.
But in this case, we want to rename multiple files at once. So we need to use wildcards. We can use wildcards * or ? for this purpose.
To get all file name with a defined name length
If we use ? then it will accept any alphanumeric character.
????.PDF will accept all PDF files that have name with 4 characters long:
To get all file name with undefined name length
The * wildcard will accept all characters regardless how many character they have.
*-Layout1.PDF will accept all files that end with –Layout1.PDF
- Floor Plan-Layout1.PDF
*-Layout*.PDF will accept all files that has –Layout in the file name, with PDF as file extension.
- Floor Plan-Layout1.PDF
- Site Plan-Layout2.PDF
Using rename command
Now that we understand how to use wildcards, let’s see how to use rename command with wildcards.
Now let’s see how we can use wildcards when renaming the files.
The command above will try to find all PDF files, then rename them. It keeps only first 4 characters, ignore the file name after 4th character.
We have a small problem. In this example you can see AS-01-Layout01.PDF is renamed to AS-0.PDF. We want the result to be AS-01, not AS-0. We need the result as 5 characters for this particular file.
We need to make a better file name pattern. Let’s try again.
This command will rename the files as follows
As you can see, the AS-01 was not renamed. You can use rename command again here if you have many files like this. If there’s only one, you can also rename it from File Explorer.
Creating a batch file
If you need to do this regularly, it’s a good idea to create a batch file. Especially if you have multiple file pattern.
You can create a batch file using notepad. Type each command in separate lines like below.
This batch file will run the rename command twice, for 2 different file name pattern.
After you created it, save it with .bat as file extension. When you save from notepad, use double quote (“) like below.
When you need to rename files in a folder, just copy this batch file to the folder. Double click to execute the commands.
Not every problem can be solved from within AutoCAD. Sometimes we need to improve and use other tools. Command prompt and batch file is a great tool, and knowing them will help.
Do you have any other command prompt and batch file experience that you can share with fellow CAD users? Share them here!
Special thanks to Hai Le for the great tip!
I use, Batch Rename Files Tool. You can easily found hier BatchRenameFiles.org that allows you to quickly rename all the files in a specified directory.
your example only allows for the characters at the start of the file name to be kept.
How you adapt the code to keep the last six characters of the file name instead?
You may want to try Bulk Rename Utility. It’s easier to use. And it has preview to let you know the file name after the process is done.
I use Ant Renamer on a USB stick.
For more complicated renames, it takes some planning and may require several passes but it can be done.
I found creating batch file very useful but if previous name include space ” “, this didn’t work, Can anyone help me solve this problem. Thank in advance !
Can you give some file names example? I tried file names with spaces, it works fine here.
@EdwinPrakoso: Thanks , i put double quote mark ” ” and it works :)
Good to know that you figure it out!
I think you should give KrojamSoft a try. This is what I use all the time when I want to rename/adjust multiple files at once. Plus, it’s a very user-friendly program that has heaps of interesting features that just makes your life so much easier when it comes to organizing and cataloging your photos, music, or anything, basically.
another method would be with visual lisp, using vl-file-rename
"Bulk Rename Utility" is a very powerful utility that can do almost anything you want with multiple file names including generating names from scratch by different indexing methods. The user interface can look a bit intimidating at the beginning and you might better retain a backup of your first rename trial until you get a grip of the utility. The utility can be googled and downloaded from various sites.
If you are in the Mac, you can use Automator to batch rename files with drag & drop ease. Also, I use PathFinder (a Finder replacement) that has a batch renaming function that is very straightforward.
Thank you for sharing Jim.
I never use Mac, so it's good that someone who does sharing about this.
You could also try out a utility called 'Renamer'. Very good programme.
Do you have the link Paul?