• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Making a Folder with Test Files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making a Folder with Test Files


  • Subject: Making a Folder with Test Files
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 10 May 2017 10:21:23 -0500

Hey Folks,

Yesterday I needed to create and recreate on demand a folder full of test files, because I needed to prevent system-caching from changing the speed at which the test set was operated on.

I hadn't looked at Satimage's Files.osax for a while, but I noticed it on their companion osax page the other day and downloaded it.

It has some nice goodies in it, and I thought I'd try them out with a little project to automate creating my test sets.

It makes for some nicely compact and very fast code.  (Sub-1-second on my system.)

------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/05/10 09:50
# dMod: 2017/05/10 10:10
# Appl: Files.osax
# Task: Create a Folder with a given number of test files from a template.
# Libs: None
# Osax: Files.osax, Satimage.osax
# Tags: @Applescript, @Script, @Files.osax, @Satimage.osax, @Create, @Folder,@Number, @Test, @Files, @Template
------------------------------------------------------------------------------

set numberOfTestFiles to 1000

set targetFolder to "~/Downloads/Test_1000_Files"
set templateFile to POSIX path of ((path to home folder as text) & "test_directory:Many_Files_1000:test_file_0001.txt")
set baseName to "Test_File_"

try -- fail if directory already exists
    set targetFolder to mkdir targetFolder with recursively -- create directory tree as necessary
end try

repeat with i from 1 to numberOfTestFiles
    set newFileName to baseName & (format i into "0000") & ".txt"
    set resultFilesList to filecopy templateFile to targetFolder name newFileName with replacing
end repeat

------------------------------------------------------------------------------

I may emplace a display dialog command to enter the number for numberOfTestFiles, but I'm going to play with it as it is for a while first.

There's also a Satimage.osax dependency for the format command.

Enjoy.

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Inserting a Custom Header in BBEdit
  • Next by Date: Re: sub-routines' error
  • Previous by thread: Re: Inserting a Custom Header in BBEdit
  • Next by thread: Skim
  • Index(es):
    • Date
    • Thread