Jump to content

Exclude file types in dircopy


Recommended Posts

  • Moderators

xcopy has an EXCLUDE feature, run this to see your command line options:

Run(@ComSpec & " /k xcopy /?", "", @SW_SHOW)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Is there a way to exclude certain filetypes in a dir copy? For example, excluding .mpg or .mp3 files when copying My Docs? TIA

something like:

#Include <File.au3>
$yourpath = "C:\"
$dest = "E:\"
$files = _FileListToArray($yourpath,'*.*',1)
for $i = 1 to $files[0]
if StringRight($files[$i],3) <> "mpg" then ;don't copy files with .mpg extension
FileCopy($yourpath & $files[$i], $dest & $files[$i],1)
endif
next
Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

Is there a way to exclude certain filetypes in a dir copy? For example, excluding .mpg or .mp3 files when copying My Docs? TIA

Try good ol' xcopy with the EXCLUDE option set. It is a DOS command that should handle all the heavy lifting for you. For example,:

xcopy "c:\source" "c:\destination" /EXCLUDE:excludes.txt

where excludes.txt contains the following entry:

.mp3

This would copy all files from "c:\source" to "c:\destination", but would exclude all files with extensions matching ".mp3". You could wrap this call inside of the _RunDos UDF.

For more info on xcopy, check here or open a DOS console and enter 'xcopy /?'. Hope this helps!

Zach...

EDIT: corrected misuse of argument.

Edited by zfisherdrums
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...