Author Topic: Simple Batch Copy and Rename?  (Read 1403 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Simple Batch Copy and Rename?
« on: November 03, 2016, 10:58:22 AM »
I know I asked this awhile ago. It was more geared towards DOS.

https://www.theswamp.org/index.php?topic=46502.msg567302#msg567302

But I stumbled on this Lisp routine and was wonder if it could do somewhat of the same?

https://www.theswamp.org/index.php?topic=30704.msg362918#msg362918

What I am playing with is:

The user can select a folder.

Then User selects a Target Folder.

At the command prompt: User can add a Prefix to all the (dwgs) that are in the source folder. (i.e. VOID-....FileName.dwg)

Then the command would copy all the dwgs within the source folder. Copy them to the target folder and finally add the prefix to all the dwgs.

Is this something that can be done?

Thanks for the feedback guys!
Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Simple Batch Copy and Rename?
« Reply #1 on: November 03, 2016, 02:21:59 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:batchcopyprefix ( / des pre src )
  2.     (and (setq src (LM:browseforfolder "[ Select SOURCE folder ]" nil 512))
  3.          (setq des (LM:browseforfolder "[ Select TARGET folder ]" nil   0))
  4.          (setq pre (getstring t "\nSpecify filename prefix <none>: "))
  5.          (foreach dwg (vl-directory-files src "*.dwg" 1)
  6.              (vl-file-copy (strcat src "\\" dwg) (strcat des "\\" pre dwg))
  7.          )
  8.     )
  9.     (princ)
  10. )

You'll need to have my Browse for Folder function loaded prior to running the above.

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Simple Batch Copy and Rename?
« Reply #2 on: November 03, 2016, 02:39:14 PM »
Thanks Lee... So Simple...  I need a brain :knuppel2:
Civil3D 2020