I'm looking for a LISP Routine that I could run that will do the following:
1. Run the publish command
2. Allow me to select drawings to publish
3. Rename all to something I type in (i.e. a job number shared by each file)
4. Keep the Layout tab as a suffix (like normal)
The end result would be publishing multiple sheets with the same prefix followed by the sheet number which is matched by the layout tab:
21.0005.00 - E0.01
21.0005.00 - E1.01
21.0005.00 - E1.02
etc.
My company has been doing this manually for some time now, and I am very new to figuring out the coding language. Does anyone know if this can be done?
Solved! Go to Solution.
I'm looking for a LISP Routine that I could run that will do the following:
1. Run the publish command
2. Allow me to select drawings to publish
3. Rename all to something I type in (i.e. a job number shared by each file)
4. Keep the Layout tab as a suffix (like normal)
The end result would be publishing multiple sheets with the same prefix followed by the sheet number which is matched by the layout tab:
21.0005.00 - E0.01
21.0005.00 - E1.01
21.0005.00 - E1.02
etc.
My company has been doing this manually for some time now, and I am very new to figuring out the coding language. Does anyone know if this can be done?
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
You could install MS Powertoys and use Power Rename for this.
You can also add a prefix to multiple files like so without installing anything:
You could install MS Powertoys and use Power Rename for this.
You can also add a prefix to multiple files like so without installing anything:
From what I understand, this bulk renaming feature will only work to remove or add similar text across several files, is that correct?
I need something that can take this list:
21.0005.00 - E0.01 - E0.01
21.0005.00 - E1.01 - E1.01
21.0005.00 - E2.01A-B - E2.01A
21.0005.00 - E2.01A-B - E2.01B
21.0005.00 - E2.02 - E2.02
Into this list:
21.0005.00 - E0.01
21.0005.00 - E1.01
21.0005.00 - E2.01A
21.0005.00 - E2.01B
21.0005.00 - E2.02
It wouldn't be an issue, but sometimes the list is 100 files long lol.
From what I understand, this bulk renaming feature will only work to remove or add similar text across several files, is that correct?
I need something that can take this list:
21.0005.00 - E0.01 - E0.01
21.0005.00 - E1.01 - E1.01
21.0005.00 - E2.01A-B - E2.01A
21.0005.00 - E2.01A-B - E2.01B
21.0005.00 - E2.02 - E2.02
Into this list:
21.0005.00 - E0.01
21.0005.00 - E1.01
21.0005.00 - E2.01A
21.0005.00 - E2.01B
21.0005.00 - E2.02
It wouldn't be an issue, but sometimes the list is 100 files long lol.
Give this a try. It will rename a directory of PDF's that match a file pattern of "* - *.pdf"
(defun c:foo (/ dir fls n p pf str)
;; RJP » 2022-04-07
(cond ((and (setq p (getvar 'dwgprefix))
(setq dir (getfiled "\nPick a folder to process..." p "pdf" 16))
(setq fls (vl-directory-files (setq dir (vl-filename-directory dir)) "*-*.pdf" 1))
(/= "" (setq pf (getstring "\nEnter prefix: " t)))
)
(foreach f fls
(setq n (substr f (vl-string-position (ascii "-") f 0 t)))
(or (vl-file-rename (strcat dir "\\" f) (strcat dir "\\" (strcat pf (+ 2 n))))
(princ (strcat "\nERROR RENAMING: " f))
)
)
)
)
(princ)
)
Not a ton of error checking so test it out!
Give this a try. It will rename a directory of PDF's that match a file pattern of "* - *.pdf"
(defun c:foo (/ dir fls n p pf str)
;; RJP » 2022-04-07
(cond ((and (setq p (getvar 'dwgprefix))
(setq dir (getfiled "\nPick a folder to process..." p "pdf" 16))
(setq fls (vl-directory-files (setq dir (vl-filename-directory dir)) "*-*.pdf" 1))
(/= "" (setq pf (getstring "\nEnter prefix: " t)))
)
(foreach f fls
(setq n (substr f (vl-string-position (ascii "-") f 0 t)))
(or (vl-file-rename (strcat dir "\\" f) (strcat dir "\\" (strcat pf (+ 2 n))))
(princ (strcat "\nERROR RENAMING: " f))
)
)
)
)
(princ)
)
Not a ton of error checking so test it out!
@daniel.orourkeUWE7W wrote:
1. Run the publish command
2. Allow me to select drawings to publish
3. Rename all to something I type in (i.e. a job number shared by each file)
4. Keep the Layout tab as a suffix (like normal)
What you're saying is by skipping item # 3 the result is just a pdf with the layout names YES?
E0.01
E1.01
E1.02
..
You can piggy-back a lisp with publish, however it may require a bit of setup on your end.
As an alternative, You can run a program to rename the resulting pdfs from publish similar to @ronjonp contribution and as originally suggested.
(defun c:AddprefixToPDF ( / prefix path pdfs)
(if (and
(setq prefix (getstring "\nEnter prefix: "))
(setq path (strcat (acet-ui-pickdir "Select Folder" (getvar 'dwgprefix))))
(setq pdfs (vl-directory-files path "*.pdf" 1))
(setq path (strcat path "\\"))
)
(foreach itm pdfs
(cond
((vl-string-search prefix itm) );<-- to avoid accidentally doubling up
((vl-file-rename (strcat path itm)
(strcat path prefix " - " itm))
)
)
)
)
(princ)
)
I'm pretty sure you are aware of the options in publish command
Otherwise use @ronjonp code to "correct" the existing pdfs.
HTH
@daniel.orourkeUWE7W wrote:
1. Run the publish command
2. Allow me to select drawings to publish
3. Rename all to something I type in (i.e. a job number shared by each file)
4. Keep the Layout tab as a suffix (like normal)
What you're saying is by skipping item # 3 the result is just a pdf with the layout names YES?
E0.01
E1.01
E1.02
..
You can piggy-back a lisp with publish, however it may require a bit of setup on your end.
As an alternative, You can run a program to rename the resulting pdfs from publish similar to @ronjonp contribution and as originally suggested.
(defun c:AddprefixToPDF ( / prefix path pdfs)
(if (and
(setq prefix (getstring "\nEnter prefix: "))
(setq path (strcat (acet-ui-pickdir "Select Folder" (getvar 'dwgprefix))))
(setq pdfs (vl-directory-files path "*.pdf" 1))
(setq path (strcat path "\\"))
)
(foreach itm pdfs
(cond
((vl-string-search prefix itm) );<-- to avoid accidentally doubling up
((vl-file-rename (strcat path itm)
(strcat path prefix " - " itm))
)
)
)
)
(princ)
)
I'm pretty sure you are aware of the options in publish command
Otherwise use @ronjonp code to "correct" the existing pdfs.
HTH
@daniel.orourkeUWE7W wrote:
From what I understand, this bulk renaming feature will only work to remove or add similar text across several files, is that correct?
I need something that can take this list:
21.0005.00 - E0.01 - E0.01
21.0005.00 - E1.01 - E1.01
21.0005.00 - E2.01A-B - E2.01A
21.0005.00 - E2.01A-B - E2.01B
21.0005.00 - E2.02 - E2.02
Into this list:
21.0005.00 - E0.01
21.0005.00 - E1.01
21.0005.00 - E2.01A
21.0005.00 - E2.01B
21.0005.00 - E2.02
It wouldn't be an issue, but sometimes the list is 100 files long lol.
Easy peasy.
Total/Windows Commander HERE. Total must-have.
@daniel.orourkeUWE7W wrote:
From what I understand, this bulk renaming feature will only work to remove or add similar text across several files, is that correct?
I need something that can take this list:
21.0005.00 - E0.01 - E0.01
21.0005.00 - E1.01 - E1.01
21.0005.00 - E2.01A-B - E2.01A
21.0005.00 - E2.01A-B - E2.01B
21.0005.00 - E2.02 - E2.02
Into this list:
21.0005.00 - E0.01
21.0005.00 - E1.01
21.0005.00 - E2.01A
21.0005.00 - E2.01B
21.0005.00 - E2.02
It wouldn't be an issue, but sometimes the list is 100 files long lol.
Easy peasy.
Total/Windows Commander HERE. Total must-have.
This program looks like it does exactly what I am looking for, but it seems to only be a month trial version that later requires a paid license to use. I'd like to avoid additional subscriptions if at all possible. Thanks for the suggestion, though!
This program looks like it does exactly what I am looking for, but it seems to only be a month trial version that later requires a paid license to use. I'd like to avoid additional subscriptions if at all possible. Thanks for the suggestion, though!
This comes incredibly close to what I'm looking for! Here are my results from running the script:
Original Files:
Renamed Files:
As you can see, an extra character is being generated at the end of the job number.
For this example, I need the list to read as shown here:
This comes incredibly close to what I'm looking for! Here are my results from running the script:
Original Files:
Renamed Files:
As you can see, an extra character is being generated at the end of the job number.
For this example, I need the list to read as shown here:
My friend, you have done it! Thank you so much! I did not notice the check box earlier to not use the sheet title with file name. After simply unchecking that box, I can just enter the job number with your script. Perfect!
My friend, you have done it! Thank you so much! I did not notice the check box earlier to not use the sheet title with file name. After simply unchecking that box, I can just enter the job number with your script. Perfect!
No subscription, just a 27 euro lifetime license.
Even if you exceed the monthly trial, the program continues to work without further restrictions.
Just try it and you'll see.
The productivity of working with multiple files cannot be compared with MS Explorer.
No subscription, just a 27 euro lifetime license.
Even if you exceed the monthly trial, the program continues to work without further restrictions.
Just try it and you'll see.
The productivity of working with multiple files cannot be compared with MS Explorer.
@daniel.orourkeUWE7W wrote:
This comes incredibly close to what I'm looking for! Here are my results from running the script:
Original Files:
Renamed Files:
As you can see, an extra character is being generated at the end of the job number.
For this example, I need the list to read as shown here:
Try my code above again. All I changed was:
;; This
(strcat pf n)
;; to this
(strcat pf (+ 2 n))
;; Test example
(SETQ STR "22.0001.00 - E0.1-E0.1.pdf")
(strcat "22.0001.000 - " (substr STR (+ 2 (vl-string-position (ascii "-") STR 0 t))))
;; "22.0001.000 - E0.1.pdf"
@daniel.orourkeUWE7W wrote:
This comes incredibly close to what I'm looking for! Here are my results from running the script:
Original Files:
Renamed Files:
As you can see, an extra character is being generated at the end of the job number.
For this example, I need the list to read as shown here:
Try my code above again. All I changed was:
;; This
(strcat pf n)
;; to this
(strcat pf (+ 2 n))
;; Test example
(SETQ STR "22.0001.00 - E0.1-E0.1.pdf")
(strcat "22.0001.000 - " (substr STR (+ 2 (vl-string-position (ascii "-") STR 0 t))))
;; "22.0001.000 - E0.1.pdf"
If you use the method below you don't need to check for an existing prefix as it will always strip everything before the last "-" 😎
(setq n (substr f (vl-string-position (ascii "-") f 0 t)))
If you use the method below you don't need to check for an existing prefix as it will always strip everything before the last "-" 😎
(setq n (substr f (vl-string-position (ascii "-") f 0 t)))
It is much easier and more convenient to type and immediately get the desired file name than to rename it later.
Is not it ?
It is much easier and more convenient to type and immediately get the desired file name than to rename it later.
Is not it ?
Can't find what you're looking for? Ask the community or share your knowledge.