Script help.. find folders (title oversimplified..)
What I need:
Have list of folder names in Excel
Script uses list to find specified folders. Folders (items in list) are actually three folders deep in directory (external archive disk/dated folder/folder I want).
Script then copies folders to another location.
Basically, I have a main archive directory (Archive1). On that disk are dated folders (102013). Inside the dated folders there are anywhere from 10-20 folders.. those contain the data (study data).. and those are the folders I want. I will have a list of 50-100 data folders provided to me.. all from random dates. I dont want to manually find, then drag and drop data into new archive. I have a list.. and would like to automate this.
What I have:
Script that will find FILES.. not folders... and not in subdirectories. It does everything i need.. if I was only looking for files in one folder.
Script I have is below. If one of you kind souls would point me in the right direction, id appreciate it.
If you want to test the script below:
Make a short list in excel.. maybe just a, b, c in a column.
Create two (named mine archive and transfer) folders on your desktop.. Place three dummy files named a, b, and c in the archive folder. Run the script wile the spreadsheet is open. You will be asked to choose the archive folder. Then the transfer folder. All files from archive folder will then be copied to transfer folder. The spreadsheet will be updated to include filenames with extension in the B colum.
Script:
set studiestofind to (choose folder with prompt "Choose Archive Location")
set transferto to (choose folder with prompt "Choose the Transfer Location")
tell application "Microsoft Excel"
tell active sheet
set lastIndex to first row index of last cell of (get used range)
repeat with i from 2 to lastIndex
set tFileName to my find_filenames(get value of range ("A" & i), studiestofind)
if tFileName is not "" then -- Study Found
set r to my duplicateImage(tFileName, studiestofind, transferto)
if r is not "" then -- no error on duplicate file
set value of range ("B" & i) to tFileName
else
set value of range ("B" & i) to ""
end if
end if
end repeat
end tell
end tell
on duplicateImage(tName, iFolder, mFolder)
try
tell application "Finder" to return (duplicate file tName of iFolder to mFolder) as string
on error
return ""
end try
end duplicateImage
on find_filenames(tVal, thefolder)
--if cell begins with space or ends with space , text items of tVal return empty string, empty string added in list excludedWords
set excludedWords to {"Mini", "and", ""} -- words in Menu Item to exclude in search
set otid to text item delimiters
set text item delimiters to " "
set tWords to text items of tVal
set text item delimiters to otid
set thefolder to quoted form of POSIX path of thefolder
set myListOfWords to {}
repeat with i in tWords -- must be valid
if contents of i is not in excludedWords then set end of myListOfWords to contents of i
end repeat
if (count myListOfWords) = 1 then -- more filler i dont really understand
set i to quoted form of (tVal & ".")
-- search file name
set tpath to do shell script "cd " & thefolder & " && /usr/bin/find . -type f -maxdepth 1 -iname " & i & "*"
if tpath is not "" then return text 3 thru -1 of tpath --return name of exact match
end if
repeat with i in myListOfWords
set tPaths to do shell script "cd " & thefolder & " && /usr/bin/find . -type f -maxdepth 1 -iregex '.*[_/]" & i & "[_.].*' \\! -name '.*' "
if tPaths is not "" then
set L to paragraphs of tPaths
if (count L) = 1 then return text 3 thru -1 of tPaths -- one path found
repeat with tpath in L -- many paths found, loop each path
set isGood to false
repeat with tword in myListOfWords -- check each word of this Menu Item in tpath
if ("/" & tword & "_") is in tpath or ("/" & tword & ".") is in tpath or ("_" & tword & ".") is in tpath or ("_" & tword & "_") is in tpath then
set isGood to true
else
set isGood to false
exit repeat
end if
end repeat
if isGood then return text 3 thru -1 of tpath -- each word of this Menu Item is in name of tpath
end repeat
end if
end repeat
return ""
end find_filenames
Hello
It is not hard to modify the existing script you posted so as to retrieve directories at depth 2 but I chose to rewrite it as follows because its filtering logic is very inefficient. In the current form, the script below will retrieve directories at depth 2 in the chosen folder.
The part scripting Excel is not tested, for I don't have Excel. It might fail to set the value of cell in column B when there are multiple matches in which case the script will try to set cell value to multi-line text of every found path. If it fails, we can adjust the code to work aronud it. Your original script only processes the first matched file but I thought it's better to process every matched one.
# Notes
• Filtering logic is modified so that it is now wholly processed by find(1). Also the regexp pattern is modified so that it compares the query word with string delimited by _ and . in file name.
E.g., Given query = "apple orange bananna", the original script matches these -
apple_orange_bananna.tex
apple_bananna_orange.dvi
_bananna__orange__apple.ps
_bananna._apple._orange.pdf
_orange.blueberry_bananna_apple....djvu
but not these -
apple.orange.bananna.txt
apple_.orange_.bananna.txt
apple_orange_blueberry.html
apple_orange_bananna
The new script will match all of them except for "apple_orange_blueberry.html".
• I added code to handle NFD-NFC issue of HFS+ name. HFS+ name is represented as Unicode in NFD (Normalization Form D), while name in Excel could be in NFC (Normalization Form C), in which case find(1) will not match the name whose NFD and NFC are different. This is not a issue if name is only in a-zA-Z0-9. But, e.g., any diacriticals will cause trouble if not with special treatment.
• Script will write log to file on desktop when a) some query gives no result or b) some of the matched files/folders are not copied because item with the same name already exists in the destination.
• Script will behave (mostly) the same as the original script when you set the find parameters properties in _main() as -
-- find parameters
property type : "f" -- d = directory, f = file
property mindepth : 1
property maxdepth : 1
• Currently the value in column B will be the (list of) found and copied path(s) and not the found path(s). If you need all of the found path(s) to be put in column B, switch the following statements in _main():
set value of range ("B" & i) to my _join(return, qq) -- found and copied
--set value of range ("B" & i) to my _join(return, pp) -- found
• Script is tested under OSX 10.5.8. (except for Excel scripting)
# Script
_main()
on _main()
script o
-- directories and logfile
property srcdir : (choose folder with prompt "Choose Archive Location")'s POSIX path
property dstdir : (choose folder with prompt "Choose the Transfer Location")'s POSIX path
property logf : (path to desktop)'s POSIX path & "copy_log@" & (do shell script "date +'%F.txt'")
-- find parameters
property type : "d" -- d = directory, f = file
property mindepth : 2
property maxdepth : 2
-- working lists
property pp : {}
property qq : {}
property rr : {}
-- find & copy nodes
tell application "Microsoft Excel"
tell active sheet
set lastIndex to first row index of last cell of (get used range)
repeat with i from 2 to lastIndex
set query to value of range ("A" & i)
set pp to my find_filenames(query, srcdir, type, mindepth, maxdepth)
if pp = {} then -- not found
tell current application to set ts to do shell script "date +'%F %T%z'"
set entry to "Did not found a name with query word(s): " & query
my log_to_file("%-26s%s\\n", {ts, entry}, logf)
else
set qq to {}
repeat with p in my pp
set p to p's contents
set q to my cp(srcdir & p, dstdir, {replacing:false})
if q ≠ "" then
set end of my qq to p -- found and copied
else
set end of my rr to srcdir & p -- found but not copied
end if
end repeat
set value of range ("B" & i) to my _join(return, qq) -- found and copied
--set value of range ("B" & i) to my _join(return, pp) -- found
end if
end repeat
end tell
end tell
-- log duplicates
if rr ≠ {} then
set ts to do shell script "date +'%F %T%z'"
set entry to "Did not copy the following node(s) due to existing name in destination: " & dstdir
my log_to_file("%-26s%s\\n", {ts, entry}, logf)
repeat with r in my rr
my log_to_file("%-28s%s\\n", {"", r's contents}, logf)
end repeat
end if
end script
tell o to run
end main
on log_to_file(fmt, lst, f)
string fmt : printf format string
list lst : list of strings
string f : POSIX path of log file
local args
set args to ""
repeat with a in {fmt} & lst
set args to args & space & a's quoted form
end repeat
do shell script "printf " & args & " >> " & f's quoted form
end log_to_file
on cp(src, dstdir, {replacing:_replacing})
string src : POSIX path of source file or directory
string dstdir : POSIX path of destination directory
boolean _replacing : true to replace existing destination, false otherwise
return string : POSIX path of copied file or directory, or "" if not copied
set rep to _replacing = true
if src ends with "/" then set src to src's text 1 thru -2
if dstdir ends with "/" then set dstdir to dstdir's text 1 thru -2
set sh to "
rep=$1
src=\"$2\"
dstdir=\"$3\"
dst=\"${dstdir}/${src##*/}\"
[[ $rep == false && -e \"$dst\" ]] && exit
cp -f -pPR \"$src\" \"$dstdir\" && echo \"$dst\" || exit $?
do shell script "/bin/bash -c " & sh's quoted form & " - " & rep & " " & src's quoted form & " " & dstdir's quoted form
end cp
on find_filenames(query, dir, type, mind, maxd)
string query : space delimited words to search
string dir : POSIX path of target root directory
string type : node type to retrieve
f => file
d => directory
integer mind : min depth of nodes in dir to retrieve
integer maxd : max depth of nodes in dir to retrieve
return list : list of POSIX path of found node(s)
script o
property exclude_list : {"Mini", "and", ""} -- list of words to be excluded from query
property pp : _split(space, NFD(query))
property qq : {}
property rr : {}
-- exclude words in exclude_list from query words
repeat with p in my pp
set p to p's contents
if p is not in my exclude_list then set end of my qq to p
end repeat
-- build arguments for find(1)
(* query words are compared with tokens delimited by _ or . in file name *)
repeat with q in my qq
e.g. Given qq = {"apple", "orange", "bananna"}, rr is list of -
-iregex '.*[/_.]apple([_.].*|$)'
-iregex '.*[/_.]orange([_.].*|$)'
-iregex '.*[/_.]bananna([_.].*|$)'
( Note: |'s must be balanced even in comment... )
set q to quotemeta(q) -- quote non-alphanumeric characters to be recognised as literal in regexp
set end of rr to "-iregex '.*[/_.]" & q & "([_.].*|$)'"
end repeat
set |-iregex| to " \\( " & _join(" -and ", my rr) & " \\)"
set |-type| to " -type " & type
set |-mindepth| to " -mindepth " & mind
set |-maxdepth| to " -maxdepth " & maxd
-- build shell script
set sh to "export LC_ALL=en_GB.UTF-8
cd " & dir's quoted form & " || exit
/usr/bin/find -E . " & |-type| & |-mindepth| & |-maxdepth| & |-iregex| & " \\! -name '.*' -print0 |
/usr/bin/perl -CS -ln0e 'print substr($_, 2);'
-- run shell script
return paragraphs of (do shell script sh)
end script
tell o to run
end find_filenames
on NFD(t)
string t : source string
return Unicode text : t in NFD (Normalization Form D)
set pl to "/usr/bin/perl -CSDA -MUnicode::Normalize <<-'EOF' - \"$*\"
print $ARGV[0] ? NFD($ARGV[0]) : qq();
EOF"
do shell script "/bin/bash -c " & pl's quoted form & " - " & t's quoted form
end NFD
on quotemeta(t)
string t : source string
return string : t where all non-alphanumeric characters are quoted by backslash
set pl to "/usr/bin/perl -CSDA -e 'print quotemeta $ARGV[0];' \"$*\""
do shell script "/bin/bash -c " & pl's quoted form & " - " & t's quoted form
end quotemeta
on _join(d, tt)
string d : separator
list tt : source list
return string : tt joined with d
local astid, astid0, t
set astid to a reference to AppleScript's text item delimiters
try
set {astid0, astid's contents} to {astid's contents, {} & d}
set t to "" & tt
set astid's contents to astid0
on error errs number errn
set astid's contents to astid0
error errs number errn
end try
return t
end _join
on _split(d, t)
string or list d : separator(s)
string t : source string
return list : t splitted by d
local astid, astid0, tt
set astid to a reference to AppleScript's text item delimiters
try
set {astid0, astid's contents} to {astid's contents, {} & d}
set tt to t's text items
set astid's contents to astid0
on error errs number errn
set astid's contents to astid0
error errs number errn
end try
return tt
end _split
Hope this may help
H
Message was edited by: Hiroto (fixed some typos)
Similar Messages
-
When I try to import songs from a CD into iTunes it can't find the titles online. This wasn't a problem previously, now it is. There is nothing wrong with my internet connection. Any solutions? Help says to try again later but no luck there. I've tried multiple times with multiple CDs.
To answer the post title FireFox save all downloads automatically in the download folder, which you can find in the Documents folder. If you want to choose where to save your downloads go to tools>options>check always ask me where to save files.
Secondly, I am assuming you have IE 8 installed as this is the only version that supports this fix that is currently not in beta. Go to control panel>internet options>advanced tab and reset the settings at the bottom. This may or may not fix the problem but it is a good first step. -
Bridge CS6 Script to Find Multiple Images in Multiple folders.
Is it possible to have a script to find multiple images within multiple folders that is on a external hard drive?
For instances I have a external hard drive assuming it's for a library of pictures.
Inside this hard drive has folders named as below
1-1000
1001-2000
2001-3000
3001-4000
If I had a perfect csv file for example that calls out for specific pictures for example 2, 10,1500 and 2000 (remember think big, it may be a larger list than this it could be hundreds or thousands of pictures); is there a script that would allow me to find these images and save a copy of them on to my desktop so that way I don't have to hunt for them in the old fashion way? I can read scripts but writing them is a different story.If you want to go with Batch I would recommend creating an Action of more or less these steps:
• set the resolution to the same as the background image’s
• change the image from Background Layer to regular Layer if necessary
• convert it to a Smart Object
• add a Drop Shadow Layer Style to the image (do not use Global Angle)
• place the background image (File > Place …)
• move it behind the image layer
• Image > Reveal All
• make Selection from that layer’s transparency (cmd-click its icon in the Layers Panel) and use Image > Crop
• select and transform the image layer to fit the intended position
This would naturally work out best if the images had the same size and proportions.
For the reflection on the floor duplicate the image, flip it vertically, move it in position and reduce its opacity to maybe 10%.
Realistically you may have to hide it partially behind the pillows, a Vector Mask would be an option. -
Script to find files with same names with in a folder and it sub folders.
Looking for script to find files with same names with in a folder and it sub folders.
Are you just looking to find if any two files underneath a folder have the same name?
If you just want to know that a file named "whatever" exists in two folders, that's not too difficult, but you probably want to know the full path names.
Here's one attempt:
$ perl -MFile::Find -le 'find(\&w, "."); while (($n,$p)=each %file) {if(@{$p}>1){print join(" ",@{$p})}} sub w{push @{$file{$_}},$File::Find::name;}'That will print the pathnames on the same line of any files with the same name that appear anywhere underneath your current directory.
It's a bit long for a "one-liner", but functional.
Darren -
I need help writing a script that finds the first instance of a paragraph style and then changes it
I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style. I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style. Any help would be greatly appreciated, thanks!
Hi,
Do you mean first instance of the paragraph style
- in a chosen story;
- on some chosen page in every text frames, looking from its top to the bottom;
- in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
If story...
You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
so:
Story.findText()[0].appliedParagraphStyle = Style_1;
//==> this will change a paraStyle of 1st occurence of story to "Style_1".
If other cases...
You would need to be more accurate.
rgds -
HELP !!! - sql script to find free space in Oracle7,8,9 DB
Hi All
I got a PL/SQL script to find out free space in Oracle7,8,9 db. But because in Oracle 7 there is no maxbytes column in dba_data_files, so this script is not working. I am trying to use cursor and putting sql in a variable so that when program executes, it does not see maxbytes. But it still does not work.
Please help. !!!
Script
set feedback off;
set serveroutput on;
set termout off;
set verify off;
spool /u01/app/oracle/admin/common/bck/log/ts.log
declare
v_tablespace_name varchar2(50);
v_total_space number(12) := 0;
v_free_space number(12);
v_space number(12);
v_space_used number(12);
v_pct_free number(6,3);
v_pct_threshold number(3) := 2;
v_table_exist number(2) := 0;
v_sql varchar2(300) := 'select sum(maxbytes) from dba_data_files where TABLESPACE_NAME = tablespace_rec.tablespace_name';
TYPE t_tableref IS REF CURSOR;
t_tablecur t_tableref;
begin
for tablespace_rec in (select tablespace_name from dba_tablespaces)
loop
-- Get the total space for the current tablespace
-- if this FILEXT$ view exists then some of the datafiles have autoextend on;
select count(*) into v_table_exist from dba_tables where table_name = 'FILEXT$';
dbms_output.put_line('table count: ' || v_table_exist);
if v_table_exist = 0 then
OPEN t_tablecur for v_sql;
fetch t_tablecur into v_total_space;
CLOSE t_tablecur;
-- select sum(maxbytes) into v_total_space from dba_data_files
-- where TABLESPACE_NAME = tablespace_rec.tablespace_name;
-- v_total_space := getMaxBytes(tablespace_rec.tablespace_name);
end if;
select sum(bytes) into v_space from dba_data_files
where TABLESPACE_NAME = tablespace_rec.tablespace_name;
if (v_total_space = 0 or v_total_space < v_space) then
select sum(bytes) into v_total_space from dba_data_files
where TABLESPACE_NAME = tablespace_rec.tablespace_name;
select sum(bytes) into v_free_space from dba_free_space
where TABLESPACE_NAME = tablespace_rec.tablespace_name;
else
select sum(bytes) into v_free_space from dba_free_space
where TABLESPACE_NAME = tablespace_rec.tablespace_name;
v_space_used := v_space - v_free_space;
v_free_space := v_total_space - v_space_used;
end if;
-- calculate the percent free for the current tablespace
v_pct_free := (v_free_space / v_total_space) * 100;
if (v_pct_free < v_pct_threshold) then
dbms_output.put_line(tablespace_rec.tablespace_name|| ' - Percent Free: ' || v_pct_free
||'%');
end if;
end loop;
end;
spool off;Hi All
I got a PL/SQL script to find out free space in Oracle7,8,9 db. But because in Oracle 7 there is no maxbytes column in dba_data_files, so this script is not working. I am trying to use cursor and putting sql in a variable so that when program executes, it does not see maxbytes. But it still does not work.
Please help. !!!
Script
set feedback off;
set serveroutput on;
set termout off;
set verify off;
spool /u01/app/oracle/admin/common/bck/log/ts.log
declare
v_tablespace_name varchar2(50);
v_total_space number(12) := 0;
v_free_space number(12);
v_space number(12);
v_space_used number(12);
v_pct_free number(6,3);
v_pct_threshold number(3) := 2;
v_table_exist number(2) := 0;
v_sql varchar2(300) := 'select sum(maxbytes) from dba_data_files where TABLESPACE_NAME = tablespace_rec.tablespace_name';
TYPE t_tableref IS REF CURSOR;
t_tablecur t_tableref;
begin
for tablespace_rec in (select tablespace_name from dba_tablespaces)
loop
-- Get the total space for the current tablespace
-- if this FILEXT$ view exists then some of the datafiles have autoextend on;
select count(*) into v_table_exist from dba_tables where table_name = 'FILEXT$';
dbms_output.put_line('table count: ' || v_table_exist);
if v_table_exist = 0 then
OPEN t_tablecur for v_sql;
fetch t_tablecur into v_total_space;
CLOSE t_tablecur;
-- select sum(maxbytes) into v_total_space from dba_data_files
-- where TABLESPACE_NAME = tablespace_rec.tablespace_name;
-- v_total_space := getMaxBytes(tablespace_rec.tablespace_name);
end if;
select sum(bytes) into v_space from dba_data_files
where TABLESPACE_NAME = tablespace_rec.tablespace_name;
if (v_total_space = 0 or v_total_space < v_space) then
select sum(bytes) into v_total_space from dba_data_files
where TABLESPACE_NAME = tablespace_rec.tablespace_name;
select sum(bytes) into v_free_space from dba_free_space
where TABLESPACE_NAME = tablespace_rec.tablespace_name;
else
select sum(bytes) into v_free_space from dba_free_space
where TABLESPACE_NAME = tablespace_rec.tablespace_name;
v_space_used := v_space - v_free_space;
v_free_space := v_total_space - v_space_used;
end if;
-- calculate the percent free for the current tablespace
v_pct_free := (v_free_space / v_total_space) * 100;
if (v_pct_free < v_pct_threshold) then
dbms_output.put_line(tablespace_rec.tablespace_name|| ' - Percent Free: ' || v_pct_free
||'%');
end if;
end loop;
end;
spool off; -
I recently used an external hard drive to back up photos etc from my mac, I didn't do a full system back up. Since then a finder window titled 'client node' keeps popping up every time i hit the spacebar. Can anyone help me please stop this happening?
Click on it, choose Get Info from the File menu, and check the format.
If it's formatted as NTFS, reformat it as MS-DOS, exFAT, or Mac OS Extended (Journaled) as desired, or install software such as Paragon NTFS on the computer.
If it's formatted as FAT32 or exFAT, use the Disk Utility's Repair Disk command on it; this may also happen for a flash drive which is about to fail.
If it's formatted as Mac OS Extended, click Authenticate and provide your administrator password, or change the permissions on that specific folder in its Get Info window.
(109318) -
Help. New to scripting! Find registration colors used
Hi!
i have this script to find registration colors.... but when run in ESTK. it show errors on the below highlighted....
could anyone help out this!
error it throws is:
function myCheckForRegistration(myEvent){
var myRegistrationSwatchUsed = false;
if(app.selection.length != 0){
for(var myCounter = 0; myCounter < app.selection.length; myCounter++){
if((app.documents.item(0).selection[myCounter].fillColor ==
app.documents.item(0).swatches.item("Registration"))||
(app.documents.item(0).selection[myCounter].strokeColor ==
app.documents.item(0).swatches.item("Registration")){ error is: // expected:)
myRegistrationSwatchUsed = true;
if(myRegistrationSwatchUsed == true){
alert("The Registration swatch is applied to some of the\robjects in the selection. Did you really intend to apply this swatch?");
thanks
shil..hellow lauv!!!
i tried your command....
ungrouped the object.item(n) between OR....
function myCheckForRegistration(myEvent){
var myRegistrationSwatchUsed = false;
if(app.selection.length != 0){
for(var myCounter = 0; myCounter < app.selection.length; myCounter++){
if(app.documents.item(0).selection[myCounter].fillColor ==app.documents.item(0).swatches.item("Registration")||
(app.documents.item(0).selection[myCounter].strokeColor ==app.documents.item(0).swatches.item("Registration")){ // error is: expected:)
myRegistrationSwatchUsed = true};
if(myRegistrationSwatchUsed == true){
alert("The Registration swatch is applied to some of the\robjects in the selection. Did you really intend to apply this swatch?");
the error is:
thanks for fastidious care on my script....
shall i wait for the reply...
shil! -
Export Aperture library objects to Finder folders
Inspired by the posted message by user http://discussions.apple.com/profile.jspa?userID=616539 I wrote a script that will do the following:
1. Sync Folders/SubFolders/Albums/Projects..etc hierarchy tree from Aperture to a Finder folders tree
2. At run-time the script will creates/append to a log file under (home directory)\Library\Logs\AppleScriptExportApertureLibrary.log
3. Exports all projects images versions with embedded metadata
4. Create a file system "hard links" for each photo in the respective Albums pointing to the project folder location in order to preserve space.
5. Compare modification date on the image files and modification date within Aperture and export only modified images in order to save time for a full sync/export.
6. In interactive mode you can select Export Folder location, Aperture Library location and Projects List (project list will contain project name and internal aperture project id).
7. In non-interactive (from command line) mode there are two arguments:
7a. "quiet" - exports all projects
7b. "quiet" "Project Information" - export only certain projects. the project information can be found in the log file.
8. Remove any images or folders from Finder export directory that do not exist in Aperture database any more.
Hopefully this would help anyone who is looking to export from Aperture on a regular basis. I am not sure how it will handle large amount of photos. I tested it with 3k+ photos.
Please note that you use this script at your own risk.
Here is the script code:
global theFoldersTree_G
global theLibraryPath_G
global theProcessedProjects_G
global theSelectedProjects_G
global theAllAlbums_G
global theScriptName_G
global Sqlite_G
global ApertureLibrary_G
global numExports_G
on run argv
set Sqlite_G to "/usr/bin/sqlite3"
set ApertureLibraryPath to POSIX path of (path to home folder) & "Pictures/"
set ApertureLibrary_G to ApertureLibraryPath & "Aperture Library.aplibrary/Aperture.aplib/Library.apdb"
set exportFolder to POSIX path of (path to home folder) & "Pictures/Aperture Exports/"
set theScriptName_G to "ExportApertureLibrary"
set theSelectedProjects_G to "ALL PROJECTS"
set theFoldersTree_G to {}
set theProcessedProjects_G to {}
set theAllAlbums_G to {}
set numExports_G to 0
logEvent("Started")
set theArgv1 to {}
set theArgv2 to {}
if (count of argv) ≥ 1 then
set theArgv1 to item 1 of argv
end if
if (count of argv) = 2 then
set theArgv2 to item 2 of argv
end if
logEvent("Passed ARGV 1: " & theArgv1)
logEvent("Passed ARGV 2: " & theArgv2)
if theArgv1 is not equal to "quiet" then
set theFile to (choose file with prompt "Please choose the Aperture Library file" default location POSIX file ApertureLibraryPath) as string
set ApertureLibrary_G to POSIX path of theFile & "Aperture.aplib/Library.apdb"
set exportFolder to POSIX path of (choose folder with prompt "Please choose the export folder" default location POSIX file exportFolder) as string
end if
logEvent("ApertureLibrary_G path is set to: " & ApertureLibrary_G)
logEvent("exportFolder path is set to: " & exportFolder)
try
tell application "Aperture"
logEvent("Getting list of project path information...") of me
set SqlStatement to "
select replace(A.ZLIBRARYRELATIVEPATH,'.approject',''),A.ZUUID
from ZRKFOLDER AS A
WHERE A.ZFOLDERTYPE=2
ORDER BY A.ZNAME"
set SQLProjectUUIDPath to DB_execute(SqlStatement) of me
set theProjectsOptions to SQLProjectUUIDPath as list
set end of theProjectsOptions to "ALL PROJECTS"
logEvent("Projects list: " & theProjectsOptions as string) of me
if theArgv1 is not equal to "quiet" then
set theSelectedProjects_G to choose from list SQLProjectUUIDPath with prompt "Please choose a project(s):"
end if
if theArgv2 is not equal to {} then
set theSelectedProjects_G to theArgv2
end if
logEvent("The selected projects : " & theSelectedProjects_G as string) of me
logEvent("Getting list of libraries...") of me
set theLibraryList to every library
logEvent("Found " & (count of theLibraryList) & " libraries") of me
repeat with theLibrary in theLibraryList
set theLibraryName to name of theLibrary
logEvent("Processing library: " & theLibraryName) of me
set LibraryFolders to {}
set theProcessedProjects_G to {}
tell application "Finder"
if not (exists (POSIX file (exportFolder & theLibraryName) of me)) then
logEvent("creating new folder " & theLibraryName & " at " & exportFolder) of me
make new folder at (POSIX file exportFolder of me) with properties {name:theLibraryName}
end if
end tell
set theLibraryPath_G to exportFolder & theLibraryName & "/"
logEvent("Getting list of folders...") of me
set theFolderList to every folder of library id (id of theLibrary)
logEvent("Found " & (count of theFolderList) & " folders") of me
set theRootFolderList to {}
if theFolderList is not equal to {} then
processFoldersTree(0, theFolderList) of me
repeat with theFolder in theFolderList
if (id of theFolder) is not in theFoldersTree_G as string then
logEvent("Found root folder : " & (name of theFolder) as string) of me
set end of theRootFolderList to theFolder
set end of LibraryFolders to (name of theFolder)
end if
end repeat
end if
if theRootFolderList is not equal to {} then
processFolders(theRootFolderList, theLibraryPath_G, "projects") of me
processFolders(theRootFolderList, theLibraryPath_G, "albums") of me
else
set theProjectList to every project of library id (id of theLibrary)
set end of LibraryFolders to processProjects(theProjectList, theLibraryPath_G, "projects") of me as list
processProjects(theProjectList, theLibraryPath_G, "albums") of me
end if
logEvent("Getting list of projects...") of me
set theProjectList to every project of library id (id of theLibrary)
logEvent("Found " & (count of theProjectList) & " projects") of me
logEvent("Getting list of albums...") of me
set theAlbumList to every album of library id (id of theLibrary)
logEvent("Found " & (count of theAlbumList) & " albums") of me
set theRootProjectList to {}
if theProjectList is not equal to {} then
repeat with theProject in theProjectList
if (id of theProject) is not in theProcessedProjects_G as string then
logEvent("Found root project : " & (name of theProject) as string) of me
set end of theRootProjectList to theProject
set end of LibraryFolders to (name of theProject)
end if
end repeat
end if
set theRootAlbumList to {}
if theAlbumList is not equal to {} then
processAlbumsTree(theProjectList, theFolderList) of me
set theRootAlbumList to {}
repeat with theAlbum in theAlbumList
if (id of theAlbum) is not in theAllAlbums_G as string then
logEvent("Found root album : " & (name of theAlbum) as string) of me
set end of theRootAlbumList to theAlbum
set end of LibraryFolders to (name of theAlbum)
end if
end repeat
end if
if theRootProjectList is equal to {} then
processAlbums(theRootAlbumList, theLibraryPath_G, "albums") of me
else
processProjects(theRootProjectList, theLibraryPath_G, "projects") of me
processProjects(theRootProjectList, theLibraryPath_G, "albums") of me
if theRootAlbumList is not equal to {} then
processAlbums(theRootAlbumList, theLibraryPath_G, "albums") of me
end if
end if
cleanup(LibraryFolders, theLibraryPath_G, "all") of me
end repeat
logEvent("total exports : " & numExports_G) of me
if theArgv1 is not equal to "quiet" then
display dialog "Total image exports : " & numExports_G buttons {"OK"} with title "Aperture Library Export" with icon note
end if
end tell
on error s number i partial result p from f to t
set s to "Error: " & s
logEvent(quoted form of (s))
if theArgv1 is not equal to "quiet" then
display dialog "ERROR : " & s buttons {"OK"} with title "Aperture Library Export" with icon note
end if
end try
end run
on cleanup(theObjects, thePath, theSelection)
logEvent("Cleaning export folders...") of me
logEvent("# Objects: " & (count of theObjects)) of me
logEvent("Export Folder: " & (thePath as string))
tell application "Finder"
logEvent("Getting list of folders...") of me
set theFolderList to every folder in folder (POSIX file thePath of me)
logEvent("Found " & (count of theFolderList) & " folders") of me
logEvent("Getting list of files...") of me
set theFileList to every file in folder (POSIX file thePath of me)
logEvent("Found " & (count of theFileList) & " files") of me
repeat with theFolder in theFolderList
set theFolderName to name of theFolder
if theFolderName is not in theObjects as string then
logEvent("Moving folder " & theFolder & " to trash...") of me
move theFolder to trash
end if
end repeat
if theSelection is not equal to "folder" then
repeat with theFile in theFileList
set theFileName to name of theFile
if theFileName is not in theObjects as string then
logEvent("Moving file " & theFile & " to trash...") of me
move theFile to trash
end if
end repeat
end if
end tell
logEvent("Cleaning completed...") of me
end cleanup
on logEvent(logMessage)
set theLine to quoted form of (((current date) as string) ¬
& " : " & logMessage)
do shell script "echo " & theLine & ¬
" >> ~/Library/Logs/AppleScript" & theScriptName_G & ".log"
end logEvent
on DB_lookupProjectPath(puuid)
set SqlStatement to "
select replace(rtrim(ZLIBRARYRELATIVEPATH,'.approject'),'/',':' )
from ZRKFOLDER
where
ZUUID ='" & puuid & "'"
set SqlRecords to DB_execute(SqlStatement)
return DB_record(SqlRecords, 1, 1)
end DB_lookupProjectPath
on processFolders(theFoldersList, theFolderPath, processOrder)
logEvent("processFolders... : " & theFolderPath) of me
set arrayOfFolders to {}
tell application "Aperture"
set theCount to count of theFoldersList
set theCounter to 1
repeat with theFolder in theFoldersList
set foldersOfFolder to {}
set theFolderName to name of theFolder
logEvent("Processing folder : " & theFolderName & " (" & theCounter & "/" & theCount & ")") of me
set theCounter to theCounter + 1
set end of arrayOfFolders to theFolderName
tell application "Finder"
if not (exists (POSIX file (theFolderPath & theFolderName) of me)) then
logEvent("creating new folder " & theFolderName & " at " & theFolderPath) of me
make new folder at (POSIX file theFolderPath of me) with properties {name:theFolderName}
end if
end tell
logEvent("Getting list of album...") of me
set theAlbumsListOfFolder to every album of folder id (id of theFolder)
logEvent("Found " & (count of theAlbumsListOfFolder) & " albums") of me
logEvent("Getting list of folder...") of me
set theFolderListOfFolder to every folder of folder id (id of theFolder)
logEvent("Found " & (count of theFolderListOfFolder) & " folders") of me
logEvent("Getting list of project...") of me
set theProjectsListOfFolder to every project of folder id (id of theFolder)
logEvent("Found " & (count of theProjectsListOfFolder) & " projects") of me
if theProjectsListOfFolder is not equal to {} then
set end of foldersOfFolder to processProjects(theProjectsListOfFolder, (theFolderPath & theFolderName & "/"), processOrder) of me as list
end if
if theFolderListOfFolder is equal to {} then
set end of foldersOfFolder to processAlbums(theAlbumsListOfFolder, (theFolderPath & theFolderName & "/"), processOrder) of me as list
else
if theAlbumsListOfFolder is not equal to {} then
set end of foldersOfFolder to processAlbums(theAlbumsListOfFolder, (theFolderPath & theFolderName & "/"), processOrder) of me as list
end if
set end of foldersOfFolder to processFolders(theFolderListOfFolder, (theFolderPath & theFolderName & ":"), processOrder) of me as list
end if
cleanup(foldersOfFolder, (theFolderPath & theFolderName & "/"), "all") of me
end repeat
end tell
logEvent("processFolders completed...") of me
return arrayOfFolders
end processFolders
on processFoldersTree(theParent, theFoldersList)
logEvent("processFoldersTree...") of me
tell application "Aperture"
repeat with theFolder in theFoldersList
if theParent is not 0 then
set end of theFoldersTree_G to (id of theFolder)
end if
set theFolderListOfFolder to every folder of folder id (id of theFolder)
if theFolderListOfFolder is not equal to {} then
processFoldersTree((id of theFolder), theFolderListOfFolder) of me
end if
end repeat
end tell
logEvent("processFoldersTree completed...") of me
end processFoldersTree
on processAlbumsTree(theProjectsList, theFoldersList)
logEvent("processAlbumsTree...") of me
set theAllAlbums_G to {}
tell application "Aperture"
repeat with theProject in theProjectsList
repeat with theAlbum in (every album of project id (id of theProject))
set end of theAllAlbums_G to (id of theAlbum)
end repeat
end repeat
repeat with theProject in theProjectsList
repeat with theAlbum in (every album of every subfolder of project id (id of theProject))
set end of theAllAlbums_G to (id of theAlbum)
end repeat
end repeat
repeat with theFolder in theFoldersList
repeat with theAlbum in (every album of folder id (id of theFolder))
set end of theAllAlbums_G to (id of theAlbum)
end repeat
end repeat
end tell
logEvent("processAlbumsTree completed...") of me
end processAlbumsTree
on DB_lookupImageInfo(puuid)
set SqlStatement to "
SELECT replace(A.ZLIBRARYRELATIVEPATH,'.approject',''),strftime('%m/%d/%Y %H:%M:%S',datetime(B.ZDATELASTSAVEDINDATABASE, 'unixepoch', '+31 years','localtime'))
from ZRKFOLDER AS A,ZRKVERSION AS B
where
B.ZPROJECTUUID = A.ZUUID AND
B.ZUUID ='" & puuid & "'"
set SqlRecords to DB_execute(SqlStatement)
return {theImagePath:DB_record(SqlRecords, 1, 1), theImageDate:DB_record(SqlRecords, 1, 2)}
end DB_lookupImageInfo
on processProjects(theProjectsList, theProjectPath, processOrder)
logEvent("processProjects... : " & theProjectPath) of me
logEvent("processOrder: " & processOrder) of me
set arrayOfProjects to {}
tell application "Aperture"
set theCount to count of theProjectsList
set theCounter to 1
repeat with theProject in theProjectsList
set ProjectFolders to {}
set theProjectName to name of theProject
set end of arrayOfProjects to theProjectName
set theContinue to 0
if "ALL PROJECTS" is not in theSelectedProjects_G as string then
if (id of theProject) is not in theSelectedProjects_G as string then
logEvent("Skipping project: " & theProjectName) of me
set theContinue to 1
end if
end if
if theContinue = 0 then
-- set theProjectPath to theProjectPath & DB_lookupProjectPath(id of theProject) of me
logEvent("Processing project : " & theProjectName & " (" & theCounter & "/" & theCount & ")") of me
tell application "Finder"
if not (exists (POSIX file (theProjectPath & theProjectName) of me)) then
logEvent("creating new folder " & theProjectName & " at " & theProjectPath) of me
make new folder at (POSIX file theProjectPath of me) with properties {name:theProjectName}
end if
end tell
if processOrder is equal to "projects" then
set end of theProcessedProjects_G to (id of theProject)
logEvent("Getting list of images...") of me
set theImageList to every image version of project id (id of theProject) as list
logEvent("Found " & (count of theImageList) & " images") of me
set end of ProjectFolders to processImages(theImageList, (theProjectPath & theProjectName & "/"), "project", "JPEG - Original Size") of me as list
end if
logEvent("Getting list of subfolders...") of me
set theSubfolderList to every subfolder of project id (id of theProject)
logEvent("Found " & (count of theSubfolderList) & " subfolders") of me
logEvent("Getting list of album...") of me
set theAlbumList to every album of project id (id of theProject)
logEvent("Found " & (count of theAlbumList) & " albums") of me
if theSubfolderList is equal to {} then
set end of ProjectFolders to processAlbums(theAlbumList, (theProjectPath & theProjectName & "/"), processOrder) of me as list
else
if theAlbumList is not equal to {} then
set end of ProjectFolders to processAlbums(theAlbumList, (theProjectPath & theProjectName & "/"), processOrder) of me as list
end if
set end of ProjectFolders to processSubfolders(theSubfolderList, (theProjectPath & theProjectName & "/"), processOrder) of me as list
end if
if processOrder is equal to "projects" then
cleanup(ProjectFolders, (theProjectPath & theProjectName & "/"), "all") of me
else
cleanup(ProjectFolders, (theProjectPath & theProjectName & "/"), "folder") of me
end if
end if
set theCounter to theCounter + 1
end repeat
end tell
logEvent("processProjects completed...") of me
return arrayOfProjects
end processProjects
on exportImage(imageUUID, imageName, exportFolder, imageType, isAlbum, exportSettings, imageExt)
set imageInfo to DB_lookupImageInfo(imageUUID) of me
set imageTime to theImageDate of imageInfo as Unicode text
set imageDate to date imageTime
set isExported to 0
set imageName to imageName & imageExt
set theFile to POSIX file (exportFolder & imageName)
tell application "Finder"
set isUpdate to 0
if not (exists theFile) then
logEvent("Image does not exist in folder : " & exportFolder) of me
set isUpdate to 1
else
logEvent("Get image modification date") of me
do shell script "ls -l " & quoted form of (exportFolder & imageName)
set imageFileDate to modification date of (info for theFile)
if imageDate ≥ imageFileDate then
logEvent("Image file date: " & imageFileDate as string) of me
set isUpdate to 1
end if
end if
if isUpdate = 1 then
if exists theFile then
move theFile to the trash
end if
if isAlbum is equal to "album" then
logEvent("Creating a link for image: " & imageName) of me
set theProjectFolder to theImagePath of imageInfo
do shell script "ln " & quoted form of (theLibraryPath_G & theProjectFolder & "/" & imageName) & " " & quoted form of exportFolder
else
set isExported to 1
logEvent("Exporting image: " & imageName) of me
tell application "Aperture"
if imageType is "master" then
set settings to exportSettings
export {image version id imageUUID} using settings to POSIX path of file exportFolder metadata embedded
else
set settings to exportSettings
export {image version id imageUUID} using settings to POSIX path of file exportFolder metadata embedded
end if
end tell
end if
end if
end tell
return isExported
end exportImage
on DB_execute(SqlStatement)
try
set SqlScript to Sqlite_G & space & "-separator '|'" & space & (quoted form of ApertureLibrary_G) & space & (quoted form of SqlStatement) & " 2>&1"
set SqlResult to do shell script SqlScript
set theARray to {}
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ASCII character 13
set SqlRecords to text items of SqlResult
set AppleScript's text item delimiters to tid
return SqlRecords
on error s number i partial result p from f to t
set s to "SQL Error: " & s
logEvent(quoted form of (s)) of me
end try
end DB_execute
on DB_record(SqlRecords, row, col)
try
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "|"
set SqlCols to text items of (item row of SqlRecords)
set AppleScript's text item delimiters to tid
return item col of SqlCols
on error
return {}
end try
end DB_record
on DB_lookupRecord(SqlRecords, theReturnCol, theText, theCol)
set theResult to ""
repeat with theRow in items of SqlRecords
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "|"
set theFields to text items of theRow
set AppleScript's text item delimiters to tid
if item theCol of theFields is equal to theText then
set theResult to item theReturnCol of theFields
exit repeat
end if
end repeat
return theResult
end DB_lookupRecord
on processImages(theImageList, exportFolder, isAlbum, exportSettings)
logEvent("processImages... : " & exportFolder) of me
if exportSettings contains "JPEG" then
set imageExt to ".jpg"
else
set imageExt to ".ANY"
end if
set arrayOfImages to {}
with timeout of 6000 seconds
set theCount to count of theImageList
set theCounter to 1
repeat with theImage in theImageList
set imageUUID to id of theImage
set imageName to name of theImage
set end of arrayOfImages to imageName & imageExt
logEvent("Processing image : " & imageName & " (" & theCounter & "/" & theCount & ")") of me
set numExports_G to numExports_G + (exportImage(imageUUID, imageName, exportFolder, "version", isAlbum, exportSettings, imageExt) of me)
set theCounter to theCounter + 1
end repeat
end timeout
return arrayOfImages
end processImages
on processAlbums(theAlbumsList, theAlbumPath, processOrder)
logEvent("processAlbums... : " & theAlbumPath) of me
set arrayOfAlbums to {}
tell application "Aperture"
set theCount to count of theAlbumsList
set theCounter to 1
repeat with theAlbum in theAlbumsList
set theAlbumName to name of theAlbum
logEvent("Processing album : " & theAlbumName & " (" & theCounter & "/" & theCount & ")") of me
set theCounter to theCounter + 1
set AlbumObjects to {}
set end of arrayOfAlbums to theAlbumName
tell application "Finder"
if not (exists (POSIX file (theAlbumPath & theAlbumName) of me)) then
logEvent("creating new folder " & theAlbumName & " at " & theAlbumPath) of me
make new folder at (POSIX file theAlbumPath of me) with properties {name:theAlbumName}
end if
end tell
logEvent("Getting list of images...") of me
set theImagesList to every image version of album id (id of theAlbum)
logEvent("Found " & (count of theImagesList) & " images") of me
if processOrder is equal to "albums" then
set end of AlbumObjects to processImages(theImagesList, (theAlbumPath & theAlbumName & "/"), "album", "JPEG - Original Size") of me as list
cleanup(AlbumObjects, (theAlbumPath & theAlbumName & "/"), "all") of me
end if
end repeat
end tell
logEvent("processAlbums completed...") of me
return arrayOfAlbums
end processAlbums
on processSubfolders(theSubfoldersList, theSubfolderPath, processOrder)
logEvent("processSubfolders... : " & theSubfolderPath) of me
set arrayOfSubfolders to {}
tell application "Aperture"
set theCount to count of theSubfoldersList
set theCounter to 1
repeat with theSubfolder in theSubfoldersList
set theSubfolderName to name of theSubfolder
logEvent("Processing subfolder : " & theSubfolderName & " (" & theCounter & "/" & theCount & ")") of me
set theCounter to theCounter + 1
set end of arrayOfSubfolders to theSubfolderName
tell application "Finder"
if not (exists (POSIX file (theSubfolderPath & theSubfolderName) of me)) then
logEvent("creating new folder " & theSubfolderName & " at " & theSubfolderPath) of me
make new folder at (POSIX file theSubfolderPath of me) with properties {name:theSubfolderName}
end if
end tell
set SubfoldersFolders to {}
logEvent("Getting list of albums ...") of me
set theAlbumsListOfSubfolder to every album of subfolder id (id of theSubfolder)
logEvent("Found " & (count of theAlbumsListOfSubfolder) & " albums") of me
logEvent("Getting list of subfolders...") of me
set theSubfoldersListOfSubfolder to every subfolder of subfolder id (id of theSubfolder)
logEvent("Found " & (count of theSubfoldersListOfSubfolder) & " subfolders") of me
if theSubfoldersListOfSubfolder is equal to {} then
set end of SubfoldersFolders to processAlbums(theAlbumsListOfSubfolder, (theSubfolderPath & theSubfolderName & "/"), processOrder) of me as list
else
if theAlbumsListOfSubfolder is not equal to {} then
set end of SubfoldersFolders to processAlbums(theAlbumsListOfSubfolder, (theSubfolderPath & theSubfolderName & "/"), processOrder) of me as list
end if
set end of SubfoldersFolders to processSubfolders(theSubfoldersListOfSubfolder, (theSubfolderPath & theSubfolderName & "/"), processOrder) of me as list
end if
cleanup(SubfoldersFolders, (theSubfolderPath & theSubfolderName & "/"), "all") of me
end repeat
end tell
logEvent("processSubfolders completed...") of me
return arrayOfSubfolders
end processSubfoldersIf you do externalize your Masters to folders anywhere (same drive, internal/external drive, multiple drives, whatever), never be tempted to use Finder to mess with them.
As Frank said, use Relocate Masters. Otherwise you'll confuse Aperture when it wakes up expecting Masters to be in certain places when they have moved elsewhere.
It's possible to fix up the mess, but it's no fun! -
Just wanted to get maybe a few new free scripts and wondering if anyone is willing to share any links or code of cool scripts they have in their arsenal that just makes things easy for them.
Here's some of my favourties that I've accumulated over the years
Apply Clipping Path
For some reason clipping paths may or not be applied to your photohsop files. If you turn on or off the clipping path for one image, then select the rest of the images and run the script it will apply or unapply the clipping path!
Create Hex Swatches
Speaks for itself really
http://indesignsecrets.com/create-hexadecimal-color-swatches-in-indesign-for-interactive-d ocuments.php
Footnotes to Endnotes
Various reasons for doing this, mainly because indesign can't handle spanning footnotes across two columns!
But it's very handy and has a lot of uses!
http://www.kahrel.plus.com/indesign/foot_to_endnote.html
This script takes it one step further by creating the cross-reference, if you need that functionality
http://www.kahrel.plus.com/indesign/foot_add_delete.html
*****FAVOURITES COMING UP******
Multipage Importer
Import and place multiple PDF pages or InDeisgn Pages directly into your indesign document!
http://indesignsecrets.com/zanelli-releases-multipageimporter-for-importing-both-pdf-and-i ndd-files.php
Preptext
There others mentioned in the link below. But Preptext is fantastic for taking in Word file that has no styles applied to it's text and it creates the bold, italic, bold italic, superscript, subscript or any other character formating into Character Styles!
It's really fantastic!
http://indesignsecrets.com/free-scripts-help-fix-word-formatting.php
Smart Title Case
You can edit the script easily enough and follow the format to add in your own conjunctions, or to add in your own intentional capital letters.
The link to download is on the left
http://jsid.blogspot.ie/2006/06/smart-title-case-revisited.html
Table Sort
Does what it says on the tin - it sorts a table, quite nifty!
http://www.kahrel.plus.com/indesign/tablesort.html
Data merge into a table
InDesigns Data Merge is quite powerful but it doesn't allow data merging into a table, say for a table plan of guests or something like that.
This resolves that issue
Follow the instructions carefully!
http://indesignsecrets.com/using-data-merge-to-create-a-table-for-a-directory.php
Replace Text
Have to replace your text with Lorem Ipsum for some reason? I requested this script and you follow the thread below
http://forums.adobe.com/thread/574682
Stylighter
Highlights styles within text - I find it handy for if you need multiple people to proof text - but there's bound to better uses than that!
http://indesignsecrets.com/style-highlighting.php
Batch Convert
This is Golden! You can select a folder of InDesign files and choose an output method, from IDML, to Package, to JPEG, to whatever else is mentioned in the conversion options.
Tips:
Set your JPEG export options by exporting a sample page first. As you don't get a dialog to choose what JPEG settings you want to choose, it uses the last JPEG setting you choose.
Setup a PDF export option so it's available to choose if you're batch exporting PDFs.
Run with no documents open to select a folder. Run with a lot of documents already open and it will use them.
http://www.kahrel.plus.com/indesign/batch_convert.html
Finally!
PageExporterUtility
It basically lets you select what pages to export to a specific format - it's very handy and easy to use.
I use it mostly for RTFs as InDesigns RTF export is a bit dodgy.
(the Batch Convert above for RTFs of multiple files is just pure golden!
http://www.rrdonnelley.com/prepress/prepare/indesign/indesign-exporter-utility-script.aspx
That's it
Hope to hear from the rest of you guys on the scripts that make your life handier while using InDesign!Good idea for a thread!
One script that I use regularly and is very useful is the late Teus de Jong's HyphenationChecker. This displays a complete list of all hyphenated words used in a document so that you can double-check them at a glance. Available here:
http://www.teusdejong.nl/thome/ho_body5.html#hyphen
I also must mention a couple of my own freebies, both of which I use regularly. I'll just copy the blurb from my site:
Quick Apply with Next Style
Have you always wished that the quick-apply feature would respect your paragraph style’s Next Style setting? Have you always wished that there would be an easy shortcut for Next Style? Well, now there is!
Case Cycle
This little script is a great timesaver. It simply cycles through three of InDesign’s capitlization options: All caps, lowercase, sentence case.
They can both be accessed from this page: http://www.freelancebookdesign.com/scripts -
Hi there,
For SharePoint 2010 site - Does someone have the PowerShell script to find a string of characters in Office/Word/Excel/PDF documents in document libraries or the ones attached to List Items?
Thanks so much in advance.Hi,
According to your description, my understanding is that you want to find some specific string character in list items using PowerShell Command.
$w = Get-SPWeb "http://devmy131"
$l = $w.GetList("http://devmy131/lists/fieldslist");
$i = $l.Items[0]["Title"].ToString();
if ($i -like '*document*')
Write-Host "Title contains document character" $i;
More information:
PowerShell -contains -like
Thanks
Best Regards
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
VB Script to find the last modified file and time in a directory
Hi,
I am new to VB script i need a script to find the latest modifed file and last modifed time in a directory(Contains folders and sub folders inside it). it has to go through all the folders and get the latest file and last modifed time.Thanks it worked for me Get-ChildItem C:\Users\sujith.reddy.komma\Desktop\Suj1\* -recurse |?{-not $_.PsIsContainer} |Sort LastWriteTime -desc | select -first 1 now in my script i have hard coded the directory i need to run this script in different
servers from one location i will put all the different paths in one text file and ineed to pass them to this script can you help me with this?
Essentially you are incrementally asking us to write each line for you. I recommend freeing yourself of this misery and leraning PowerShell. THe answers to all of your questions are learned in the first few hours of study.
Start here:
http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx
¯\_(ツ)_/¯ -
I'm an IBM guy and I was assigned this MAC projet. I'm a MAC noob. I have a multi-user eMac. The user account folders are blown away when the computer shuts down leaving just the root accout and default account. I included a new javapolicy file in the default user account. A file called java.policy resides in the user home folder at log in (/users/johndoe/java.policy) for every new user that logs in. I need to create a logon shell script that finds the java.policy file in their home folder and renames it .java.policy to make it hidden. Remaming it in the default profile is not an option, and I don't know who will be using the computer at any given day. Can someone help me with the code.
#!/bin/bash/
I'm clueless, thanks for the helpThe generic bash rename syntax for your specified command is:
mv /Users/shortuser/javapolicy /Users/shortuser/.java.policy
Here's a typical script:
#!/bin/bash
mv /path/to/source/.java.policy /Users/shortuser/.java.policy
The most direct mechanism would be via a computer login preference and workgroup manager, setting up a script that executes at user login. That script is invoked at login and can copy over or create the required file. Another of the usual techniques for executing commands at login is the so-called [login hook (HT2420)|http://support.apple.com/kb/HT2420], though if you're using Open Directory (OD) or OD with Active Directory (AD), it'll probably be better to go that way than the login hook.
Other discussions [here|http://arstechnica.com/civis/viewtopic.php?f=20&t=416343] and [here|http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-appl et.html]
I'd tend to expect to see the policytool used for this file, too. Launch Terminal.app and see +man policytool+ for details on that.
I'd also tend to expect to see this sort of stuff established within the system-wide policy module from the JRE that's usually located in [the system library directory |http://stackoverflow.com/questions/4372060/java-security-file-location-on-mac- snow-leopard] (/Library/Java/Home/lib/security/java.policy) and not with a per-user setting, too, and that's a rather different approach than populating the per-user settings. (But then I'm not a Java geek.)
FWIW, it's "Mac" and not "MAC", it's Unix, and files and directories doesn't get blown away unless there's a problem somewhere, or unless this is a school or kiosk or other environment that's using specific system-reset processing. And if there's system-reset processing here, then you'll obviously need to work within that. That processing is usually associated with OD, hence the earlier pointers. (And if there's this sort of reset processing going on, there's usually a reason for it, I'd probably try to keep as much sensitive stuff out of the local directories as I could reasonably manage.) -
How to query XML file RDL SSRS Report to find column titles?
I have list of SSRS reports theirRDL file. How can we query the file to find like text book name as below( <Textbox Name="bippie_passed_qa_photostamps_orders_amount">). Catlog t able in report server does not provide column title
but i am trying to find column title through RDL file. How can we query in SQL server 2012 version too? I am new in XML please help is appreciated.
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="bippie_passed_qa_photostamps_orders_amount">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!bippie_passed_qa_photostamps_orders_amount.Value</Value>
<Style>
<FontSize>8pt</FontSize>
<Format>'$'#,0.00;('$'#,0.00);''</Format>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>You will first need to get your report XML from the dbo.Catalog table but something like this should work:
-- !!TODO get your report XML from the dbo.Catalog table
DECLARE @ssrsXML TABLE ( yourXML XML )
INSERT INTO @ssrsXML
SELECT '<TablixCell>
<CellContents>
<Textbox Name="bippie_passed_qa_photostamps_orders_amount">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!bippie_passed_qa_photostamps_orders_amount.Value</Value>
<Style>
<FontSize>8pt</FontSize>
<Format>''$''#,0.00;(''$''#,0.00);''''</Format>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
</Textbox>
</CellContents>
</TablixCell>'
SELECT t.*, c.c.value('@Name', 'VARCHAR(100)' ) nameProperty
FROM @ssrsXML t
CROSS APPLY yourXML.nodes('//TablixCell/CellContents/Textbox' ) c(c) -
PS Script to find the list of users and the groups in a Workgroup server
Hi There, could you please explain on how to get a complete list of local users and local groups in a "Workgroup" server to which they belong to using Powershell. I'm able to get the users list but couldn't find any help in finding
the script to find to which localgroup the user belong to. Anticipating your response. Also let me know the cmdlet for Win2k3 servers to find the same.Here's some code from David Pham (don't remember wher I fund this code):
Trap {"Error: $_"; Break;}
Function EnumLocalGroup($LocalGroup)
$Group = [ADSI]"WinNT://$strComputer/$LocalGroup,group"
"Group: $LocalGroup"
# Invoke the Members method and convert to an array of member objects.
$Members= @($Group.psbase.Invoke("Members"))
ForEach ($Member In $Members)
$Name = $Member.GetType().InvokeMember("Name", 'GetProperty', $Null, $Member, $Null)
$Name
# Specify the computer.
$strComputer = gc env:computername
"Computer: $strComputer"
$computer = [adsi]"WinNT://$strComputer"
$objCount = ($computer.psbase.children | measure-object).count
$i=0
foreach($adsiObj in $computer.psbase.children)
switch -regex($adsiObj.psbase.SchemaClassName)
"group"
{ $group = $adsiObj.name
EnumLocalGroup $group }
} #end switch
$i++
} #end foreach
Maybe you are looking for
-
Using a repeater to pass content to a title window
Hi I have a repeater that has a button and the button open a title window component from flex So far I use the name property of the button to pass the title from the repeater to the title of the titlewindow here it is: Vimeo is the name of the repeat
-
Can't enter text in threaded frame
How basic can this be? After writing one book I'm preparing master pages for a second. When I created this document I selected the "master" option I've copied master spreads in the lower frame of the Pages box. I liked several frames on the spreads t
-
I am stuck in a photo album with no button to go back! If I press the home button I get back to the main iPhone screen, when I go back to the Facebook app, it brings me straight back to the photo again with no option to et put of there?!
-
Folio builder panel problem on login
Updated my folio builder panel and now when I login it tells me I have to update eventhough I just did. Am I the only one with this problem? T.
-
How to disable guest user account on iMAC
I upgraded to Lion and now I have a guest user account on the log in screen. I want to disable this account. How do I get rid of it?