Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 15, 2009, 12:59 AM   #1
laynef
macrumors newbie
 
Join Date: Oct 2009
Copy names of folders, inside a folder and paste to a text doc

Hi, I'm trying to write an applescript to help me archive. I need a script to copy the names of the folders (which are jobs) and paste them into a text file.
laynef is offline   0 Reply With Quote
Old Oct 15, 2009, 01:12 AM   #2
chown33
macrumors 603
 
Join Date: Aug 2009
In Finder:
1. Open the folder.
2. Select all (command-A).
3. Copy (command-C).

In TextEdit:
4. Open a new or existing document.
5. Paste (command-V).

It took me at least 10 times longer to write this than to perform the actions.

Do you really need to write a script? Are these actions going to be performed repeatedly, without human intervention?

If you need a script, try this example:

Code:
list folder (path to home folder)
Paste it into Script Editor and run it. Note that it returns a list. So walk the list, or remove its first item until it's empty, appending each name to a string. Finally, write the string to a file.

If you can't figure it out from the example, please describe your scripting experience, and whether it needs to list the contents of a certain fixed folder, or the contents of any folder you choose.

Last edited by chown33; Oct 15, 2009 at 01:40 AM.
chown33 is offline   0 Reply With Quote
Old Oct 15, 2009, 05:37 AM   #3
mysterytramp
macrumors 65816
 
mysterytramp's Avatar
 
Join Date: Jul 2008
Location: Maryland
You don't need to walk the list. This will return a return-delimited list:

Code:
set dummyList to list folder (path to home folder)
set TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set dummyList to dummyList as text
set AppleScript's text item delimiters to TID
dummyList
mt
__________________
What looks large from a distance, close up ain't never that big.
mysterytramp is offline   0 Reply With Quote
Old Oct 15, 2009, 06:02 AM   #4
Angelo95210
macrumors 6502a
 
Angelo95210's Avatar
 
Join Date: Jan 2009
Location: Paris, France
Or there is a little free piece of software named "Print Window" that does it very well. Exports to excel, with spotlight comments etc.
__________________
Hackintosh G31M-S2L - Macbook 3,1
Angelo95210 is offline   0 Reply With Quote
Old Oct 15, 2009, 10:05 AM   #5
laynef
Thread Starter
macrumors newbie
 
Join Date: Oct 2009
Ok the copy and paste didn't work, it just pasted the folder icons into a text document. I tried the other script and that worked, although it made the of text go from 10,11,12,13,14,2,3,4,5,6,7,8,9. Is there any way to do it numerically? It doesn't matter that much, my next question is I can get it work on my local computer by using the path "Macintosh_HD:Users:admin:test"
Where Macintosh_HD is my computer and test is the folder I want to get the names out of. How do I do this off a mounted volume? I can't get it read off of there. This is what the path would be using UNC \\xraid1\Rsi Jobs.standby
my other question is there is a space in the folder name, will it let me use the name with a space?
laynef is offline   0 Reply With Quote
Old Oct 15, 2009, 10:15 AM   #6
Darth.Titan
macrumors 68020
 
Darth.Titan's Avatar
 
Join Date: Oct 2007
You need to go to the Format menu and click "Make Plain Text" before pasting in TextEdit.
Darth.Titan is offline   0 Reply With Quote
Old Oct 15, 2009, 08:47 PM   #7
mysterytramp
macrumors 65816
 
mysterytramp's Avatar
 
Join Date: Jul 2008
Location: Maryland
Quote:
Originally Posted by laynef View Post
Is there any way to do it numerically?
If you add the leading zero to the file name, it will:

01, 02, 04=3, 04 ,05, 06, 07, 08, 09, 10, 11, etc.

but if the files are named 1, 2, 3, 4, ... you'll get what you found.

Quote:
Originally Posted by laynef View Post
How do I do this off a mounted volume?
You have a couple of options. You can hard code the path:

set dummyList to list folder ("Volume name:First Folder:Second Folder:Third Folder") -- see? it works with spaces

You can also use a Posix path:

set dummyList to ("/Library/Contextual Menu Items/")

or you could give yourself more options by saying:

set dummyList to list folder (choose folder)

mt
__________________
What looks large from a distance, close up ain't never that big.
mysterytramp is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
copy multiple file names > then paste to multiple different files maxslomoff Mac Programming 5 Jul 27, 2014 09:52 AM
Need app to copy/paste text into messages or whatsapp wannabelean iPhone and iPod touch Apps 3 Feb 9, 2014 07:35 PM
Copy and paste of folders problem theslaz iMac 2 Oct 28, 2012 04:59 PM
Copy and Paste two pieces of text latestmonkey OS X 10.8 Mountain Lion 5 Oct 26, 2012 11:59 AM
How to: Copy and Paste text from books in iBooks Jimmy Guphanti iPad 2 Sep 20, 2012 05:32 AM

Forum Jump

All times are GMT -5. The time now is 08:39 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC