Below is a script that will list all folders whose parent folder is “orders”
Is it possible to exclude folders who are in the same level while using the shell command "find " - I guess it’s much faster than what I have right now. (lot of folders to scan)
Hierarchie:
TESTARCHIVE
A
A_cust1
base
orders
cards
A_cust2
base
orders
cards
B
B_cust1
base
orders
cards
B_cust2
base
orders
cards
and so on…
property TESTARCHIVE : "/TESTARCHIVE"
property textpath : "~/Desktop/testplus.txt"
property the_separator : "@"
set scan_level to "4"
do shell script ("find " & TESTARCHIVE & " -depth " & scan_level & " -type d")
set results to the result
set master_list to {}
repeat with i from 1 to (count of paragraphs of results)
if paragraph i of results contains "orders" and paragraph i of results does not end with "orders" then
copy paragraph i of results to end of master_list
end if
end repeat
--choose from list master_list
set new_master_list to {}
repeat with this_master_item in master_list
set oldDels to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
try
set theText to text item 6 of this_master_item
if theText is not in new_master_list then copy theText to end of new_master_list
end try
set AppleScript's text item delimiters to oldDels
end repeat
--choose from list new_master_list
(* the last part is for testing, the final output will be based on questions like "remove job?" and "archive job?"
use the final output for auto archive or remove*)
repeat with this_new_master_item in new_master_list
do shell script "echo " & quoted form of this_new_master_item & the_separator & "Arch" & " >>" & textpath
end repeat
I don’t get your point 100%, but here are some find examples, that might help
runs in a directory with folders named:
test1
orders new
test 2
orders
find ./ -iname ‘orders?*’ -type d
→ finds orders new a ? stands for one any characters (but only one) and * stands for any characters… ans many as you want
find ./ -iname ‘orders*’ -type d
→ finds orders new and orders
find ./ ! -iname ‘orders*’ -type d
→ finds test1, test2 with a ! infront of a find option you negate this option, in this case find every directory that does not start with orders…
What I need is a list of all folders in all the folders called “orders”.
I need it because i have another script that has to read the output of this script (text file)
"this_master_item of {"/TESTARCHIVE/A/AAP/orders", "/TESTARCHIVE/A/ABC/orders", "/TESTARCHIVE/A/ABN Amro/orders", "/TESTARCHIVE/A/About Blank/orders", "/TESTARCHIVE/A/Acanthus/orders", "/TESTARCHIVE/A/ACC/orders", "/TESTARCHIVE/A/ACE/orders", "/TESTARCHIVE/A/AD Production/orders", "/TESTARCHIVE/A/ADC/orders", "/TESTARCHIVE/A/Admo/orders", "/TESTARCHIVE/A/Advantage-design/orders", "/TESTARCHIVE/A/AdviesPas/orders", "/TESTARCHIVE/A/Advise Mechanical Solutions/orders", "/TESTARCHIVE/A/Aeromech/orders", "/TESTARCHIVE/A/Ahold/orders", "/TESTARCHIVE/A/Air Aroma/orders", "/TESTARCHIVE/A/Akro/orders", "/TESTARCHIVE/A/Al-Falk/orders", "/TESTARCHIVE/A/Albatros/orders", "/ kan niet worden opgevraagd. "
It’s in Dutch but nevertheless I hope that someone can help me with this problem.
–The echo part works so i’m puzzled…
here’s my second script:
property TESTARCHIVE : "/TESTARCHIVE"
property textpath : "~/Desktop/joblist_test.txt"
property the_separator : "@"
set folder_exclusions to {"basis", "visitekaartjes"}
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "\" -or -name \""
set exclude_code to text 2 thru -1 of ("" & ({""} & folder_exclusions)) & "\""
set AppleScript's text item delimiters to ASTID
set scan_level to "3"
set scan_level2 to "1"
do shell script "/usr/bin/find " & (quoted form of TESTARCHIVE) & " ! \\( -name \".DS_Store\"" & exclude_code & " \\) -depth " & scan_level & " -type d"
set results to the result
set master_list to {}
repeat with i from 1 to (count of paragraphs of results)
copy paragraph i of results to end of master_list
end repeat
repeat with this_master_item in master_list
do shell script "echo " & quoted form of this_master_item & " >>" & textpath
end repeat
--choose from list master_list
repeat with this_master_item in master_list
do shell script "/usr/bin/find " & quoted form of this_master_item & " -depth " & scan_level2 & " -type d"
end repeat
set job_results to the result