Better way to backup multiple extensions within a folder?

Discuss and share scripts and script files...
Post Reply
roy.lambert
Posts: 45
Joined: 20 May 2009 11:30

Better way to backup multiple extensions within a folder?

Post by roy.lambert »

I'm playing with backupto. I'm happy with what I've done but always like to know if there's a better way.The script is

"Backup TfR source";
set $bk, "E:\HH Dev\TfRSource\*";
set $pas, "$bk.pas";
set $dfm, "$bk.dfm";
set $ini, "$bk.ini";
set $inc, "$bk.inc";
set $dll, "$bk.dll";
set $dpr, "$bk.dpr";
set $res, "$bk.res";
set $cfg, "$bk.cfg";
set $drc, "$bk.drc";


backupto "\\NLHZERO\Backups\Delphish\TfRSource\TfRSource <date yyyy-mm-dd>", "$pas|$dfm|$inc|$ini|$dll|$dpr|$res|$cfg|$drc";
Last edited by TheQwerty on 12 Nov 2014 19:17, edited 1 time in total.
Reason: More specific title.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Is there a better way

Post by TheQwerty »

Hmm.. try this:

Code: Select all

"Backup TfR source"
  $bk = "E:\HH Dev\TfRSource";
  // Extensions to backup.
  $exts = "*.pas|*.dfm|*.ini|*.inc|*.dll|*.dpr|*.res|*.cfg|*.drc";
  // Get a list of all files in $bk.
  $files =ListFolder($bk,, 1);
  // Filter the list to only those matching $exts - also sort & remove dupes/empties.
  $files = FormatList($files, 'fdents', '|', $exts);
  backupto "\\NLHZERO\Backups\Delphish\TfRSource\TfRSource <date yyyy-mm-dd>", $files;

roy.lambert
Posts: 45
Joined: 20 May 2009 11:30

Re: Better way to backup multiple extensions within a folder

Post by roy.lambert »

Thanks

I don't know if its any better but it certainly has opened my eyes. I hadn't realised how full the language was.

Its certainly given me some ideas as to how I can copy a full tree and then delete selected files based on extension from each folder. I could hard code it but there may be folders added later.

Post Reply