Author Topic: How do you name your files  (Read 4922 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How do name files
« Reply #15 on: September 21, 2005, 02:21:44 PM »
Guess:

for %f in (file*) do copy "%f" ..\doc\
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Birdy

  • Guest
Re: How do name files
« Reply #16 on: September 21, 2005, 02:34:31 PM »
Thanks. That makes sense.
Although I've never done anything like THAT before....
....I'll be a-cussin' when I need to though.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: How do name files
« Reply #17 on: September 21, 2005, 02:39:13 PM »
Guess:

for %f in (file*) do copy "%f" ..\doc\

Thanks MP!!

Code: [Select]
C:\Temp\work\spaces>for %f in (file*) do copy "%f" ..\doc\

C:\Temp\work\spaces>copy "file one" ..\doc\
        1 file(s) copied.

C:\Temp\work\spaces>copy "file three" ..\doc\
        1 file(s) copied.

C:\Temp\work\spaces>copy "file two" ..\doc\
        1 file(s) copied.

C:\Temp\work\spaces>copy "file1" ..\doc\
        1 file(s) copied.

C:\Temp\work\spaces>copy "file2" ..\doc\
        1 file(s) copied.

C:\Temp\work\spaces>copy "file3" ..\doc\
        1 file(s) copied.
TheSwamp.org  (serving the CAD community since 2003)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: How do name files
« Reply #18 on: September 21, 2005, 02:56:29 PM »
see .. I tol' ya it plays hell with programming ..
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Bob Wahr

  • Guest
Re: How do name files
« Reply #19 on: September 21, 2005, 02:58:18 PM »
that was programming?

FWIW, copy file* ..\doc\ should work and have the same end result(I think).
« Last Edit: September 21, 2005, 03:04:46 PM by Bob Wahr »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How do name files
« Reply #20 on: September 21, 2005, 03:04:54 PM »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: How do name files
« Reply #21 on: September 21, 2005, 03:11:01 PM »
that was programming?

FWIW, copy file* ..\doc\ should work and have the same end result(I think).
Perhaps it might ... however you should remember that this was a very simple example.

Something a little more complex that would not work in your instance is this little snippet I use to remove all BAK files from my drawing folders ...
Code: [Select]
@echo off
::Change the next line to the root of where you want to start deleting *.bak files
::Mine starts in c:\drawings
set BEGINPATH=c:\Drawings\
For /F "tokens=1* delims= " %%f in ('dir /a /s /b %BEGINPATH%*.bak') do erase "%%f %%g"
set BEGINPATH=
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Bob Wahr

  • Guest
Re: How do name files
« Reply #22 on: September 21, 2005, 03:25:02 PM »
Code: [Select]
@echo off
::Change the next line to the root of where you want to start deleting *.bak files
::Mine starts in c:\drawings
set BEGINPATH=c:\Drawings\
del /f/q/s %beginpath%\*.bak
set BEGINPATH=

Better yet, kill em all and let the backup file fairy sort em out
Code: [Select]
@echo off
del /f/q/s c:\*.bak

TR

  • Guest
Re: How do name files
« Reply #23 on: September 21, 2005, 04:11:06 PM »
Here's an easier way. You can call "delbak" on as many directories as your heart desires. You need the python interpreter of course.
Code: [Select]
'''
file: deletebak.py
desc: A simple script for looping through a directory
      and it's subdirectories deleting all files with
      the extension .bak.
auth: Tim Riley (riltim@gmail.com)
date: 21-Sep-05
'''
import sys, os, string

def delbak(deldir):
    for root, dirs, files in os.walk(deldir):
        for fname in files:
            file, ext = os.path.splitext(fname)
            if string.lower(ext) == ".bak":
                os.remove(os.path.join(root, fname))
                print "Removed ", os.path.join(root, fname)

if __name__ == "__main__":
    delbak(r'c:\test')

results:
Quote
Removed  c:\test\Copy of location.bak
Removed  c:\test\Copy of Single User Batch Plot Error Report.BAK
Removed  c:\test\New Folder\Copy of Adesk_Subscription.BAK
Removed  c:\test\New Folder\Copy of AU05_Online_Catalog.bak
Removed  c:\test\New Folder\Copy of Developer.BaK
Removed  c:\test\New Folder\Copy of IP_Sample.bAK

Bob Wahr

  • Guest
Re: How do name files
« Reply #24 on: September 21, 2005, 04:22:22 PM »
A way, yes.  I'm not sure how it's an easier way though.

TR

  • Guest
Re: How do you name your files
« Reply #25 on: September 22, 2005, 09:13:44 AM »
A way, yes.  I'm not sure how it's an easier way though.

Yeah I guess it's not really an easier way. :)

However it will work the same on Windows, Linux/Unix, Mac OSX, etc., all you need to do is replace r"c:\temp\" with r"\home\bwahr" for example. Which means you could run it on your desktop stations as well as your servers.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: How do you name your files
« Reply #26 on: September 22, 2005, 11:28:47 AM »
Here's a simple program that will delete files by extension.

Quote
delbyext version 0.1 ( Thu Sep 22, 2005 )
Copyright 2005 Mark S. Thomas ( mark@theswamp.org )

Deletes files from path ( -p ) downward given .ext ( -e )

** warning Windows users **
deleted files are NOT placed in the "Recycle Bin", use at your own risk

Only those files which are owned by the user will be deleted, all
others will be ignored.

Path will be traversed downward to the end. This means all files
which have the given .ext in the tree will be deleted.

Example:
delete all files that end with ".bak" from the directory "c:\work" and below

delbyext -e .bak -p c:\work

The "." in the extension argument is required

INSTALL
Place both files ( delbyext.exe & python24.dll ) some
where in your path.
TheSwamp.org  (serving the CAD community since 2003)