Filecopy

Discussions about tools to complement CSPro data processing
Post Reply
Romij Chowdhury
Posts: 33
Joined: August 19th, 2023, 6:06 am

Filecopy

Post by Romij Chowdhury »

Do anyone can tell me how to copy multiple files from one folder to another by using "Filecopy" Function?
justinlakier
Posts: 152
Joined: November 21st, 2022, 4:41 pm

Re: Filecopy

Post 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
Romij Chowdhury
Posts: 33
Joined: August 19th, 2023, 6:06 am

Re: Filecopy

Post 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 ?
Attachments
Filecopy.jpg
Filecopy.jpg (387.87 KiB) Viewed 12830 times
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Filecopy

Post 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);
Romij Chowdhury
Posts: 33
Joined: August 19th, 2023, 6:06 am

Re: Filecopy

Post by Romij Chowdhury »

Thank You very much Sir!!
Post Reply