Jump to content
Sign in to follow this  
grunewald6

Exclude file types in dircopy

Recommended Posts

grunewald6

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

Share this post


Link to post
Share on other sites
Authenticity

Don't think so, but you can code different file copy. For example, you can recursively build an array of files and keep out files with .mpg extension and copy them all, one by one.

Share this post


Link to post
Share on other sites
SmOke_N

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.

Share this post


Link to post
Share on other sites
maqleod

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

Share this post


Link to post
Share on other sites
zfisherdrums

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

Share this post


Link to post
Share on other sites
grunewald6

Thanks, guys. Xcopy seems to be the way to go. I miss the forest for the trees sometimes - forgetting DOS and always looking for an autoit command. Thanks again!

Share this post


Link to post
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
Sign in to follow this  

×