View Full Version : File paths question
03-27-2010, 08:08 PM
I'm launching a couple of different things using fscommand and a .bat file, which has the full path of what I'm launching (c:\\windows\etc...). since this will be on a CD, going into different computers, how to you set up the paths correctly so it still points to your file?
03-28-2010, 05:48 AM
Type set at a DOS prompt and hit return to see a list of environment variables that you can use. There should a list in the format VARNAME=value. Anything that appears on the left side of the = sign can be used in your BAT files.
For example, if you wanted to open the Windows folder is on any machine you could use the windir environment variable like this in a BAT file.
Any environment variable can be used with % signs around it in a BAT file and Windows will take care of expanding it to the full value at runtime.
NOTE: Check with Windows help to make sure the environment variable you want to use is a standard one created by Windows and not by an application you might have installed because anyone can register new environment variables.
I hope that helps :)
03-29-2010, 01:49 AM
03-29-2010, 02:49 AM
Alright.. I don't seem to get it. I checked the set list in dos, and looked up the environment list online, but I don't see one for a CD drive.
Thinking into this further... since all my bat files are doing is launching PDFs in the fscommand folder, do I need to know the CD drive letter? Or is there something equivalent to actionscript's "this." command. The pdfs are in the same folder as the .bats.
CD drive > fscommand > files and .bats
03-29-2010, 01:16 PM
Aha! http://www.allenware.com/icsw/icswref.htm Dot aliasing is just what I was looking for. It references the local folder without having to know it's drive letter.
03-29-2010, 01:51 PM
If you're running from a CD you can reference any folder on the CD using an absolute path without the drive letter like \fscommand\file.odf so you don't need to use the "." or ".." relative paths (if that makes things a little easier).
03-29-2010, 03:14 PM
Indeed. Thanks again!
...You wouldn't happen to know how to do the same thing with apple scripts by any chance? ..Opening windows and pdfs?
03-29-2010, 06:42 PM
Give this a whirl...
tell application "Finder"
select file "file.pdf" of folder "MyPDFFiles" of disk "MyCD"
03-29-2010, 06:58 PM
Excellent! Thank you. I'll check this out tonight on my woman's mac.
03-30-2010, 07:46 PM
Alright, I've gotten this to work while all of my files are in a folder, so I write:
select folder "myFolder" in folder "my other folder"
but I've kind of run into the same problem as before. I'm not sure how to target the CD drive, or keep the search within the same folder.
I've tried just writing:
select folder "myFolder'
And sticking that script in the same folder as the folder I want to launch, but it returns an error (Can't remember which one, I'm back on a PC now).
I guess the way around my problem, is to name the CD something specific, and then modify the apple script any time I change the CD name. This way I can add "of disk "myCD" to the end of the script?
It's tricky to do this having only periodic access to a mac..
03-30-2010, 10:27 PM
Yep of disk "DiskName" is the trick you need to use.
There are solutions that use the current folder to figure out the path to the file dynamically but they'll require a little more work. Here's an example...
--set the name of the file to open
property fileName : "test.pdf"
--get the path to the containing folder
set myPath to (path to me as string)
set AppleScript's text item delimiters to ":"
set the parentFolder to ¬
((text items 1 thru -2 of myPath) & "") as string
set AppleScript's text item delimiters to ""
--find the file
set targetFile to alias (the parentFolder & fileName)
--if there's no file here by this name, it will quit
--open the file
tell application "Finder"
open file targetFile
03-31-2010, 01:22 AM
... I'll go the of disk "DiskName" route.
03-31-2010, 07:00 PM
I did a test burn and encountered this error:
"can't get the file "bios.pdf" of <class cfol> "fscommand" of <<class cdis>> "myCD" of application "Finder."
My test actionscript:
bio.onRelease = function()
if (System.capabilities.os.substr(0, 3) == "Win")
output.text = "launching bios.";
else if (System.capabilities.os.substr(0, 3) == "Mac")
output.text = "mac bio button";
tell application "finder"
select file "bios.pdf" in folder "fscommand" of disk "myCD"
I named the disk "myCD" when I burned it with nero. Where did I go wrong?
vBulletin® v3.8.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.