Page 1 of 1

Filecopy

Posted: November 13th, 2023, 7:05 am
by Romij Chowdhury
Do anyone can tell me how to copy multiple files from one folder to another by using "Filecopy" Function?

Re: Filecopy

Posted: November 13th, 2023, 9:32 am
by justinlakier
See the FileCopy Documentation. You can use the wildcard characters "*" and "?" to specify a group of files to copy as the filename, and list the folder as the output file name. Example 2 uses a wildcard in this way.

You can also use the DirList function to get a list of all files in a directory, then loop through that list and copy any or all files from that directory to another. This method is more effort for the same result but may allow more control if you want to copy only some of the files from the folder, and those files cannot be specified using wildcards.

Hope this helps,
Justin

Re: Filecopy

Posted: November 15th, 2023, 8:48 am
by Romij Chowdhury
Please explain me the wildcard example of "Filecopy" step by step bcz i cant understand that example.....in that example in the picture below in red rectangular mark what will be the directory? is it the file directory or where i want to copy that file that directory ?

Re: Filecopy

Posted: November 15th, 2023, 9:44 am
by Gregory Martin
Let's say that I have a subdirectory, Images, located in the directory where my application is. CSPro evaluates paths based on the application directory, so if you wanted to copy all files in Images to a backup directory named after the current timestamp, you might have code like this:
// create a backup directory
string backupDirectory = maketext("Image-Backup-%d", timestamp());
dircreate(backupDirectory);

// copy all files from the Images directory into the backup directory
filecopy("Images/*.*", backupDirectory);

Re: Filecopy

Posted: November 15th, 2023, 11:44 pm
by Romij Chowdhury
Thank You very much Sir!!