[JS] Date Variable in File Path

Hello,
I have simple script that is placing files on to the page.
var myDate = new Date();
var myDay=myDate.getDate();
var myMonth=myDate.getMonth() + 1;
var myYear=myDate.getFullYear();
var myTotal = myDay + "/" + myMonth + "/" + myYear;
var myDoc = app.activeDocument;
var afile = File("/Files/max/Desktop/'myTotal'_name.txt") >>>>Could please someone suggest how I can use variable myTotal - as prefix for the name of the file ? I need to open files with actual date
var bfile = File("/Files/max/Desktop/b.txt")
var cfile = File("/Files/Max/Desktop/c.txt")
if (!afile.exists || !bfile.exists || !cfile.exists)
alert ("Text file missing...")
else
myDoc.textFrames.item("a").parentStory.insertionPoints.item(-1).place(afile);
myDoc.textFrames.item("b").parentStory.insertionPoints.item(-1).place(bfile);
myDoc.textFrames.item("c").parentStory.insertionPoints.item(-1).place(cfile);
Thank you

The argument to File(...) is a simple text string, and simple text strings are concatenated using the + operator:
a = "b";
b = "c";
c = a+b; -> c = "bc";
You are complicating things by mixing both single and double quotes. Javascript accepts either, but the same ones must be used for both opening and closing a string.
Instead of
("/Files/max/Desktop/'myTotal'_name.txt"
use
("/Files/max/Desktop/"+myTotal+"_name.txt")
By the way, as you can see in your own File(..) line, the forward slash is defined as a path separator. It's possible you have a folder structure "Files", containing "max", containing "Desktop", but since you add 'myTotal' to the mix -- which also contains forward slashes -- you have to ensure all path elements in that exist as well.
(As it seems you were not intending that, I'd suggest using other date separators than forward -- or backward! -- slashes.)

Similar Messages

  • System information - create date, file paths, etc

    How do I add system information to the master page of a form so that I can see the create date, last
    updated, page numbers and file path information and have it printed on the bottom of each page?

    You can access the Doc object that is exposed in the Acrobat JavaScript API.
    For example,
    var doc = event.target;
    xfa.host.messageBox("Author " + doc.author + " Created date " + doc.creationDate + " File path " + doc.URL);
    See Doc API reference at
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.375.html
    Steve

  • Read table data and fetch file from path specified in table column

    Hi,
    I have a situation where file path information is stored in database table along with other columns - I need to read data from SQL Server table row by row, go to the path identified by the record, check for existance of the file - if the file is available copy it to a staging area, then read the next record. Repeat this process until the last record is fetched from the table. At the end, zip all the files found and FTP to a different location. If the file is not found in the path specified, write the database record to a seperate text file.
    At end of the process, send an email with records for which files were not found at specified location.
    Thanks
    Edited by: user4566019 on Oct 5, 2008 4:32 AM

    Hi,
    That is not complex to solve at ODI.
    Try the following.
    1) Create a package
    2) create a variable to receive the path as parameter and drag and drop it at package as "Declared"
    3) drag and drop the ODI Tool "odiFileMove" using and let the variable as patch at ODI Tool parameter.
    Use the parameters -ACTION=MOVE -TIMEOUT=100 and -NOFILE_ERROR=NO (take a look at ODI Toos Reference for other parameters)
    3) Create a "KO" (error) flow to write the variable at a text file. That will allow the process knows what file is missing
    4) generate a scenario of this package
    5) create a procedure
    6) at first step, put the query from SQL Server (set the Logical Schema to the right connection)
    7) at Target tab, put the call to the scenario generated using the returned value from query parameter. Plus, let the -SYNC_MODE=1. That will call one scenario by time.
    8) create a new step to zip the files at stage directory
    9) create a step to make the ftp
    10) create a step to mail the txt generated with files not founded. If you wish, you can make a validation on the file to see if is necessary to send the mail, it means, if there is any file missing.
    Does it help you?

  • SSIS - Loop through files from a file path based on the value in the variable

    Experts,
    I have a requirement where I'll be loading multiple files in to a SQL server table and archive the files when loaded. However, the challenge is , the file path should be dynamic based on the value of a variable (say, @ProductName).
    For example: If I am running the package for variable @ProductName="Product", the file path would be "\\....\Src\Product", in that case the ForEachLoop will loop through all the files in that folder, load them to the table and Archive
    the files to the "\\....\Src\Product\Archive" folder.
    Similarly, if the @ProductName="Product_NCP", the foreachloop container should loop through files in the "\\....\Src\Product_NCP" folder, load them to the table and archive them to the ""\\....\Src\Product_NCP\Archive"
    folder.
    Any suggestions? I should be able to run the package manually just by passing the "@Product" value, create Archive folder if it doesn't exist, load the data and archive the files.

    Yes
    1. Have a variable inside SSIS to get folder path. Set path based on your rule using an expression
    like
    (@[User::ProductName] == "Product" ? "\\....\Src\Product" : (@[User::ProductName] == "Product_NCP" ? \\....\Src\Product_NCP:..))
    similary archive
    (@[User::ProductName] == "Product" ? "\\....\Src\Product\Archive" : (@[User::ProductName] == "Product_NCP" ? "\\....\Src\Product_NCP\Archive" :..))
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Search c:\ drive and return file path for winword.exe and save as variable

    Hi all, here is what I'm trying to do;
    1. Search C:\ drive for winword.exe
    2. take the file path and save it as a variable.
    3. Then based on the path value, use the switch statement to run "some command" 
    Essentially I'm trying to find what the file path for winword.exe is, then run a command to modify the registry.  I already have the script that will modify the registry like I want but the problem it, the path is hard coded in the script, I want to
    now look for all versions of word and set the right file path so I can make the right registry changes.

    This should get you started:
    http://ss64.com/ps/get-childitem.html
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Formula variable with replacement path on system date

    Hi Experts,
    I got a requirement to calculate "Days without payment" in report level.
    Days without payment = System Date - Payment Date.
    (Payment date field is available in CUBE, but system date field is not available in the CUBE)
    As we know, the difference b/w 2 dates is not possible directly.It can be possible by creating 2 formula variables with replacement paths on the dates and by writing aformula on these 2 formula variables.
    But the thing is I dont have system date readily available, and I tried by using SAP Exit. But we cant create formula variable replacement path on another variable (SAP EXIT).
    Do we have any SAP variable  for formula with replacement path readily avaliable to get system date (or) any other suggession.
    Please suggest me.
    Thanks,
    Sai Chand.S

    Hi Arminder,
    Thanks for your valuable answer.
    I tried doing the same previously.As u said we can get system date by creating customer exit variable.
    But the thing is to find difference b/w 2 dates, we cant do it directly, we need to create 2 formula variables with replacement path.
    1) Var1 = Formula variable with replacement path on system date(custoer exit variable).
    2) Var2 = Formula variable with replacement path on paymanet date.
    Number of days = var1 - var2.
    But as in 1st point, we cant create formula variable with replacement path on another variable, as system date is already a variable of type customer exit.
    We can create replacement paths only on characteristics.
    Please suggest me .
    Thanks,
    Sai Chand.S

  • File path of open data storage

    Hello all!
    Now I'm using the blocks of open data storage, write data and close data storage for storing and extracting result data. For the file path issue, before I
    set the data path by double clicking the "open data storage" block and inserting the file location in the indicated place, and that worked!
    Now since I made a stand alone application of this program and shall use it in other computers, the file location I inserted in open data storage block isn't
    valid any more in other PCs. So I modified my source code by connecting a "current vi path" to the open data storage block's file path node instead of
    inserting it inside the block, and this doesn't work! During running there shows an error in the write data block saying that the storage refnum isn't valid!
    I'm wondering why I couldn't specify the file path like this. Any way to allow me to specify the file path as the current vi path?
    Thanks!
    Chao
    Solved!
    Go to Solution.

    You need to account for the path changes when built in to an application, have a look at this example.
    https://decibel.ni.com/content/docs/DOC-4212
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • Date formula variable with replacement path.

    Hi ,
    I have date formula variable with replacement path.
    Variable pop up with date format yyyymmdd. but i want dd.mm.yyyy.
    I have checked my user profile setting and it is dd.mm.yyyy.
    Can u please suggest it .
    Thanks
    Pramod

    Thanks for the rely , but basically i need a variable only for selection.
    thats why i have created formula variable processing my cutomer exit.
    But i think customre exit variable comes with text format .
    any1 has an idea for the same.
    Thanks
    Babu

  • How to set the file path dynamically based on sytem, username, and date

    Hi All,
    My requirement is upload the data into one  structure like xyz that is related to t.code MCSZ.
    file will be in  UNIx SERVER .
    PATH IS: /sapif
    file name is xy789 load .txt
    I have  to write code in one user-exit
    how can i set the file path for this.
    shall i put hard code file path?
    because i have to writecode in user-exit.
    plz tell me how to set the file path based ons syetem, username, date
    Thanks in advance
    Ram.A

    Concatenate the field SY-SYSID, SY-UNAME and SY-DATUM for the file path

  • Listing File, path, sizes and dates

    Hi all
    Case: I have 6 machines on one network (some with 2 drives), another on another network (connected by vpn) and 3 external drives.
    These all have accumulated stuff, some repeated as I've upgraded and re-purposed machines but left directories behind as a safeguard.
    I need to rationalise the space and develop a more systematic approach to backup and archiving.
    My first step is do an inventory of what's where and my natural approach is work with a data base of file name, path, size, created date and last modified to allow me to do some maths on archiving to dvd.
    Using find as follows
    find [Start Somewhere Directory] -print > [workspace path]/TestOutput.txt
    gives me a nice list of file name I can parse out in a database
    But I don't get size and dates.
    Adding -ls produces that info but creates header lines for parent directories and adds permissions, node and other info I don't need.
    I got to here
    find [Start Somewhere Directory] -type df -exec ls -lshk {} \; -print > [workspace path]/TestOutput.txt
    but still has the hierarchical output rather than flat paths.
    Am I doing this all the hard way ? Is there a tool that returns just what I'm looking for ?
    Or what command will allow me to take just the relevant columns form ls to the print parameter ?
    Or can I extend find to add the size and date info to the output ?
    Kind Regards
    Eric

    Eric
    I just so happened to have done something similar before!
    It relies on mdls so isn't exactly speedy, but produces a full path, size, modification date, modification time, creation date and creation time as a comma separated list. mdls is not exactly predictable as to which order you get its output, so basically you have to try first without any editing.
    Anyway, here it is:
    sudo find ~/testfolder -type f \! -name ".*" -exec echo 'mdls -name kMDItemFSSize -name kMDItemFSCreationDate -name kMDItemFSContentChangeDate "{}" | tr "\n" "," | sed "s%^\(/.*\) .*ChangeDate = \(....-..-..\) \(.*\) .CreationDate.= \(....-..-..\) \(.*\) ...00,.FSSize.= \(.*\),$%\"\1\",\6,\2,\3,\4,\5%"' \; | shI'm sure it could be improved!
    You could also do it with AppleScript, since that can access the creation date easily.

  • Get (variable) file path and name in a text element

    How do you get the (variable) file path and name in a text element (label) in LCD? If you save the PDF and afterwards relocate it, it should update the values. Is that actually possible?

    Does anyone have any advice on this issue?
    Thanks in advance,
    Zack H.

  • How do I use a UNIX environment variable for the path of a file name

    We are running Forms 6i over the web. The forms server runs on a UNIX (HP-UX) machine.
    I want to read the contents of a file, which is simple enough, using the TEXT_IO package. However, I want to reference a UNIX environment variable that specifies the file path i.e
    PROCEDURE get_file IS
    in_file Text_IO.File_Type;
    linebuf VARCHAR2(1800);
    filename VARCHAR2(200);
    BEGIN
    filename:= '$LOG_DIR/RCAS181.log';
    in_file := Text_IO.Fopen(filename, 'r');
    .....other stuff
    Notice the filename string references my unix env variable '$LOG_DIR'. However, this doesnt work. If I put the full pathname it works fine.
    Any suggestions ?

    Have a look at TOOL_ENV.GETVAR()

  • Pg Number, File path and date automatically printed?

    Is there a way to automatically print the page number, complete file path and date at bottom of each  page (set to landscape)?
    Thanks!

    Thanks Carlos,
    It looks like the work72a would work if we were using macs, but we're not...
    And there is NO WAY my boss will pay $999 for the other one, even if it did work.
    So, now I'm open to other suggestions. We have hundreds of clients that we do work for, and our jobs are organized in folders for each client. A lot of clients with the same name but different locations (ie., Fox Meadow OH, Fox Meadow TX), and each has a different folder. The files are named by dept and year (ie., 2012 Glass, 2012 Art). We often access old files (which, there are thousands of, because they have been organized this way for years.) We need to have the client folder on the page along with the file name (hence the file path).
    The script that Carlos created is great, but there are too many steps. Open the script, change location and select info to be displayed (3 steps), close script. There are days we access 50 jobs and the script just added 5 plus steps to each job.
    Is there a way to use a hot key run a script that will place the info when and where we need it and auto close the script? Or is there a way to display the full path (in the Illustrator tab?) where we can see which folder the file is in and we will manually type the folder? Or does anyone have another suggestion?

  • Create a formula variable using replacement path for current date

    Hi All,
    I created a formula variable using replacement path for current date.
    But when i used this variable am getting an error message saying .
    " This Variable cannot be used in this query".
    Could you please let me know the reason?
    Thanks,
    Zehra

    Hi All,
    Thanks for all your help...
    I just found a solution via the below link
    in Bex Formula variabel, Current calander day(sap exit) missing.
    Here he is trying to use the existing formula variable.
    My doubt here is, Even i could not find this varaible in BEX formula variable, But could see this in BI Content path as mentioned in the above link.  DO i have to transport this varaible , or i simply can activate it in production?
    I just could find this in BI Content but not in MetaData Repository.
    Thanks,
    Zehra

  • How to call a variable file path in javascript

    Hi,
    My objective is to capture a file path on mac and windows. However, this file path gets changed with various users.
    For example the path is:
    c:\user\username\AppData\Local\Temp\myfolder------> this is for windows machine
    /users/username/Library/Application Support/tempfolder/Temporary Files/-------> this is for mac machine
    As you can see, the path will be same for all the machines. Only the difference will be in searching the user and username at the start of file path. Rest folders will remain same on all the machines.
    Is there any grep pattern through which I can call this complete path in a variable for all the users.
    Any help will be appreciated.
    Regards,
    Abhi

    Hi,
    You are able to check OS:
    var currOS = $.os;
    regarding to value of this string you can switch to various paths
    Jarek

Maybe you are looking for

  • How to share files between computers and TC

    What is the best way to share content/files between computers (iMac and MacBook Pro)? I thought about using Time Capsule for this...is this NOT wise? Thanks

  • BPM: Messages stuck in Queue

    Hi All,        I am working on BPM scenario. My scenario is I am collecting 100 messages in 10 mins and sending to receiver. Here correlation I used as constant. In my deadline step I am using Transform step and Send why because if my scenario collec

  • Max line items in FI reached..

    Hi,     We are posting an invoice using MIRO and it is giving an error that "Max line items in FI has reached". So is there any way that we can post if the total line items are more than 999. Regards>

  • Place to put swing.jar to enable Swing for IE?

    I know I can extend the JVM in Netscape 4.7, or any of the JRE's from Sun by sticking extra JAR files into the lib/ext directory. Is there a similar place to do so to extend the Microsoft JVM for IE. Specifically, I want to do that for Swing. I know

  • Installing iSync Palm Conduit

    Using an iMac G5 with 10.4.3 I tried to install iSyncPalm.dmg and got the message: iSync Palm Conduites cannot be installed on this computer. iSync Palm Conduit requries iSync to be insatlled first. Problem is that iSync is installed and is visible i