Import "File Name"

Hi everyone, 
Quick question. I have written a basic scrit that imports all the columns from a .csv file into a SQL table however I wish to add an additional column that would contain the file name for each row. The reason? I'm importing a transaction file in my db however
the date of the transactions is not contained in the .csv columns but the file name.
Can someone help?
Cheers,

Hi,
Please show us what have you done, and we could help you in the next step :-)
[Personal Site] [Blog] [Facebook]
Hi, 
The script I use now to import my data is the following:
INSERT INTO [dbo].[table] SELECT * FROM OPENROWSET ('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=\\NAS\Volume_1\Data\data.xlsx',
'select * from [Sheet1$]')
Basically, I import excel files however I would like to import csv files and add an extra field name
with the file name.
Thank you

Similar Messages

  • Import file name -   want to go back to 2008-02-22 format  HELP!

    iphoto 06 imported photos into a date formatted file such as 2008-02-22. iphoto 08 makes this -February 22, 2008. I need help in just returning to the original date format as a default process.
    yes, I can do this manually but this requires additional work in Aperture (both 1.5 & 2). Thousands of photos annually make me want to make this automatic and easy. The current format is totally ridiculous, when part of an alphabetized list which renders multiple years from the same mont grouped together rather than in a time sequence a in i06

    Welcome to the Apple Discussions. What file are you referring to? Where are you seeing this date? When iPhoto 6 imports a photo the file name renames the same, whatever it was before. Am I missing something here?
    Are you referring to renaming of photos from within iPhoto with the Batch Rename feature? Then go into the System Preferences/International/Formats pane and click on Customize button. There you can reset the short, medium or long date to the YYYY-MM-DD format. Then select the sort, medium or long date in the iPhoto Batch Change window and you'll get what you want.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Import File Name Date Incorrect

    I have set import to file name format yyyy mm dd in preferences but Photoshop 11 as in 10 creates the file name in yyyy dd mm format. Is there a fix for this in both PS 10 and PS 11?

    Hi,
    There were some patches for PSE 10
    Mac: http://kb2.adobe.com/cps/930/cpsid_93...
    Win: http://kb2.adobe.com/cps/930/cpsid_93...
    Not sure about PSE 11
    Brian

  • Importing file names

    I want to create an inventory spreadsheet of my artwork jpeg files.
    How do I import into Numbers just the file names of a folder full of jpg files?
    I would like the file name to be one column and the extension another column because I also have .mov and .pdf files and would like to sort them later.
    Thanks

    Here is a script doing the entire trick.
    --[SCRIPT insertFolderContents]
    Enregistrer le script en tant que Script : insertFolderContents.scpt
    déplacer le fichier ainsi créé dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
    Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
    Sélectionner la cellule où devra être inséré le premier nom de fichier.
    menu Scripts > Numbers > insertFolderContents
    Naviguer jusqu'au dossier à examiner.
    Les noms de fichiers et leurs éventuelles extensions sont collées dans la table.
    Rien n'est collé si le dossier est vide.
    Il est également possible d'enregistrer le script sous forme de Progiciel (Application sous 10.6).
    Dans ce cas il peut être activé par un double clic ou par glisser-déposé d'un dossier sur son icône.
    --=====
    L'aide du Finder explique:
    L'Utilitaire AppleScript permet d'activer le Menu des scripts :
    Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
    Cochez la case "Afficher le menu des scripts dans la barre de menus".
    --=====
    Save the script as a Script: insertFolderContents.scpt
    Move the newly created file into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    Select the cell where filenames must be inserted.
    menu Scripts > Numbers > insertFolderContents
    Navigate to the folder to scan.
    The file names and the extension names (if they exist) are pasted in the table.
    If the folder is empty, nothing is pasted.
    Alternatively, the script may be saved as an Application package (Application under 10.6).
    In this case, it may be triggered by double click on by drag & drop of a folder on its icon.
    --=====
    The Finder's Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the "Show Script Menu in menu bar" checkbox.
    --=====
    Yvan KOENIG (VALLAURIS, France)
    2010/04/18
    --=====
    on run
    set dossier to choose folder
    --tell application "System Events" to set dossier to choose folder
    dans un bloc System Events pour avoir un titre de dialogue "localisé"
    • in a System Events block to get a localized dialog title. *)
    my main({dossier})
    end run
    --=====
    on open sel
    my main(sel)
    end open
    --=====
    on main(sel)
    my activateGUIscripting()
    set {dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
    set dossier to quoted form of POSIX path of (item 1 of sel as text)
    set lesNoms to paragraphs of (do shell script "ls " & dossier)
    if lesNoms is not {} then
    repeat with i from 1 to count of lesNoms
    set n to item i of lesNoms
    if n contains "." then
    set item i of lesNoms to n & tab & last item of my decoupe(n, ".")
    end if
    end repeat
    set the clipboard to my recolle(lesNoms, return)
    my shortcut("Numbers", "v", "cas")
    end if
    end main
    --=====
    set { dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
    on getSelParams()
    local r_Name, t_Name, s_Name, d_Name, col_Num1, row_Num1, col_Num2, row_Num2
    set {d_Name, s_Name, t_Name, r_Name} to my getSelection()
    if r_Name is missing value then
    if my parleAnglais() then
    error "No selected cells"
    else
    error "Il n'y a pas de cellule sélectionnée !"
    end if
    end if
    set two_Names to my decoupe(r_Name, ":")
    set {row_Num1, col_Num1} to my decipher(item 1 of two_Names, d_Name, s_Name, t_Name)
    if item 2 of two_Names = item 1 of two_Names then
    set {row_Num2, col_Num2} to {row_Num1, col_Num1}
    else
    set {row_Num2, col_Num2} to my decipher(item 2 of two_Names, d_Name, s_Name, t_Name)
    end if
    return {d_Name, s_Name, t_Name, r_Name, row_Num1, col_Num1, row_Num2, col_Num2}
    end getSelParams
    --=====
    set {rowNumber, columnNumber} to my decipher(cellRef,docName,sheetName,tableName)
    apply to named row or named column !
    on decipher(n, d, s, t)
    tell application "Numbers" to tell document d to tell sheet s to tell table t to return {address of row of cell n, address of column of cell n}
    end decipher
    --=====
    set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
    on getSelection()
    local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
    tell application "Numbers" to tell document 1
    repeat with i from 1 to the count of sheets
    tell sheet i
    set x to the count of tables
    if x > 0 then
    repeat with y from 1 to x
    try
    (selection range of table y) as text
    on error errMsg number errNum
    set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
    return {theDoc, theSheet, theTable, theRange}
    end try
    end repeat -- y
    end if -- x>0
    end tell -- sheet
    end repeat -- i
    end tell -- document
    return {missing value, missing value, missing value, missing value}
    end getSelection
    --=====
    on parleAnglais()
    local z
    try
    tell application "Numbers" to set z to localized string "Cancel"
    on error
    set z to "Cancel"
    end try
    return (z is not "Annuler")
    end parleAnglais
    --=====
    on decoupe(t, d)
    local l
    set AppleScript's text item delimiters to d
    set l to text items of t
    set AppleScript's text item delimiters to ""
    return l
    end decoupe
    --=====
    on recolle(l, d)
    local t
    set AppleScript's text item delimiters to d
    set t to l as text
    set AppleScript's text item delimiters to ""
    return t
    end recolle
    --=====
    on activateGUIscripting()
    tell application "System Events"
    if not (UI elements enabled) then set (UI elements enabled) to true (* to be sure than GUI scripting will be active *)
    end tell
    end activateGUIscripting
    --=====
    ==== Uses GUIscripting ====
    This handler may be used to 'type' text, invisible characters if the third parameter is an empty string.
    It may be used to 'type' keyboard shortcuts if the third parameter describe the required modifier keys.
    on shortcut(a, t, d)
    local k
    tell application a to activate
    tell application "System Events" to tell application process a
    set frontmost to true
    try
    t * 1
    if d is "" then
    key code t
    else if d is "c" then
    key code t using {command down}
    else if d is "a" then
    key code t using {option down}
    else if d is "k" then
    key code t using {control down}
    else if d is "s" then
    key code t using {shift down}
    else if d is in {"ac", "ca"} then
    key code t using {command down, option down}
    else if d is in {"as", "sa"} then
    key code t using {shift down, option down}
    else if d is in {"sc", "cs"} then
    key code t using {command down, shift down}
    else if d is in {"kc", "ck"} then
    key code t using {command down, control down}
    else if d is in {"ks", "sk"} then
    key code t using {shift down, control down}
    else if (d contains "c") and (d contains "s") and d contains "k" then
    key code t using {command down, shift down, control down}
    else if (d contains "c") and (d contains "s") and d contains "a" then
    key code t using {command down, shift down, option down}
    end if
    on error
    repeat with k in t
    if d is "" then
    keystroke (k as text)
    else if d is "c" then
    keystroke (k as text) using {command down}
    else if d is "a" then
    keystroke k using {option down}
    else if d is "k" then
    keystroke (k as text) using {control down}
    else if d is "s" then
    keystroke k using {shift down}
    else if d is in {"ac", "ca"} then
    keystroke (k as text) using {command down, option down}
    else if d is in {"as", "sa"} then
    keystroke (k as text) using {shift down, option down}
    else if d is in {"sc", "cs"} then
    keystroke (k as text) using {command down, shift down}
    else if d is in {"kc", "ck"} then
    keystroke (k as text) using {command down, control down}
    else if d is in {"ks", "sk"} then
    keystroke (k as text) using {shift down, control down}
    else if (d contains "c") and (d contains "s") and d contains "k" then
    keystroke (k as text) using {command down, shift down, control down}
    else if (d contains "c") and (d contains "s") and d contains "a" then
    keystroke (k as text) using {command down, shift down, option down}
    end if
    end repeat
    end try
    end tell
    end shortcut
    --=====
    --[/SCRIPT]
    Yvan KOENIG (VALLAURIS, France) dimanche 18 avril 2010 11:08:09

  • Changing the Word imported file name

    A lot of topics were imported as Word documents and the search results and index results refer to Word documents that were imported en masse and with inconsistent naming conventions. For example, "1 - Order Title" was renamed "Underwriting after UDSA Approval is Received" in the TOC but when a person does a search or clicks the index keyword, the original file name is given.
    Thank you very much, one day I hope to start giving back to the community.
    Dave

    I have amended your topic title to something more useful.
    There are some changes you can make. See Importing and Linking on my site. However, now the topics have been created, it's a manual change.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Automate exports and imports (file names)

    Hi all,
    I will like to do a simple export and import into another schema in another database.
    I am very comfortable with the process but all i require is how to set the dump file and log file names to be the date and name of the database being exported and imported.
    For example when I do the export I want the dump file and logfile names to be exp_ORCL_230805.dmp and exp_ORCL_230805.log for database ORCL exported on 230805.
    For the import I want the logfile name to be imp_TEST_230905.log.
    I am doing this export and import on a windows xp client but the database reside on UNIX AIX boxes.
    Thanks alot

    Set up ORACLE_SID before you start the imp/exp session on the client, then you can use file=exp_%ORACLE_SID%_%DATE%.dmp etc. (Note that if your windows locale has a date format w/ whitespace you might have to write a script to get rid of it..)

  • Find source import file name after imports

    Hi! We usually import data via Import Manager rather than using MDIS. Now, if I want to verify the file that I have used for the import, where can I find the information? I couldn't see any of these in the Report and Logs in the MDM Console.
    Appreciate any help on this.
    Cheers!
    SF

    Hi Ravi,
    This is also an alternative way of doing this if your MDIS services are not running. But Port Concept ideally should be used with MDIS, when you have created and saved Map in Port of MDM console. Is any other Privileges do we get if we do this import using MDM Import manager manually when it can be done automatically using (MDIS) as soon as there is file in MDM Inbound Ready folder. Rightly said by you , yes you can place file in Ready folder through Scripting or PI etc.
    @ SF, As per my understanding i agree you can monitor the files using Type =Port during Import Manager but i don't see any benefit of using Processing Type= Manual, if it can be automated using MDIS(if Import Server is running).
    @ Sudhanshu, So we can track the files wither port is manual or automatic I don't think we can track whether the file reaches to Archive folder from Ready folder using MDIS or through Import Manager selecting  type = Port.
    But there is one thing, whenever file disappears from Ready folder and goes to archive folder using MDIS, a log file gets generated in MDIS logs folder so this is one way using which we can come to know when was last file imported through Import server but i think we can not track from Archive  folder.
    Regards,
    Mandeep Saini

  • Import file name has "_"

    When I import my images from my Canon 5D, Lightroom 5 replaces the first character of the image name with an underscore "_".  I can't find anything in the LR preferences that would cause this. Where does this underscore come from?

    What are the imagenames on the camera itself? 
    Usually on Canon cameras if the image name begins with an underscore, followed by MG (_MG_XXXX.JPG) that means the image was saved with an AdobeRGB color information metadata and setting while sRGB usually begins with IMG followed by the image number followed by a dot with an extension (RAW or JPG)

  • Insane XML Import, Huge Project, Duplicate file names work around...

    I planned on kicking off my journey attempting to edit a massive multi year documentary on FCPX with a nice introduction of the blog I'm going to keep about the experience, but I've run into a bit of a roadblock, or maybe major speed bump at least before even getting to that point. I wanted to share what is working as a work around for me and you guys can tell me how I'm doing it wrong.
    Ok, I will try to explain this as succinctly as possible. I'll write in somewhat stream of consciousness just to try and get through it quicker... Basically, after discovering the work around below, I am now utterly confused on how FCPX handles the relationship between its own database of where media is stored, and the actual media itself. I have plenty experience on FCPX now, probably done 30-40 pro commercial jobs on it over the last year since XML became doable as I'm also a Resolve Colorist and all the FCPX projects where hardcore coloring product spots. For commercial work, I never needed to worry about splitting up footage up over multiple Events. Everything, all in one, FCPX handled it no problem. (well the occasional beach ball, but that seems to be a thing with FCPX in general)
    This will be my 10th feature documentary as an Editor. Every one before it was either on Avid's many flavors over the last 12 years or FCP Studio. When this new film came along, I made the decision a few months ago to use FCPX for a few reasons, but mostly because I'm insane and I like to try to mix it up for myself in a career that can get stale quick if you aren't willing to be that way. The film was shot over 2+ years, every shoot was multi cam 5D (yes i know, looks great, but please kill me), I haven't done the math on length, but there is over 10,000 clips of video (this is actually medium in size compared to what I've dealt with before). Its 5D, so theres external audio for everything. FCPX's syncing is great, but I've learned that theres an unsaid window of heads and tales clips must fall within to sync properly with the nearby clips, if they are too far apart FCPX gives up. One shoot day could have 3 cams, 50 clips each, and 2 audio files to sync to, FCPX simply cannot handle this, so off to Plural eyes they went, no problems.
    Ok, all this is relevant eventually I swear! Again, in the past, all in one event, no problem. I tried for fun to bring all media into one Event on this film. It worked, but there is a 10+ second spinning beach ball for every single move you make, so thats no good. Ok, I'll separate the Events out to, lets say, each shoot month. Well that's dumb, in verite documentary, any shot could be the first, any shot could be the last, you need a command over all searchable footage at all times. Shift selecting all events to search *****, and it actually takes longer for FCP to reload each event each time than it does to just have the one massive one. So no go there. Next hair brained idea... What if make a new Event that is just Compound Clips of all the other Event's contents and do more with Markers and Favorites in logging that I was planning to parse it all out. That way I'm working with and FCPX is dealing with 50-60 clips instead of 10,000+ Quick test, Cmd-A, Opt-G, boom, boom, boom, move all to dedicated to Event, hide huge Event, BEHOLD, that works! FCPX chokes a little bit on the insane length of some of the clips, but searching, and general performance is back on par!
    So your saying to yourself "Ok *********, sounds like you figured it out, what's the problem." Well to you I say, "Not so fast!" Remember, that was just a quick test using the media I had imported into the massive 10,000+ clip Event. To do this project proper, I am having to import Multicam sync'd XMLs from Plural Eyes. And this is where it all starts to fall apart. A little foreshadowing for your eager eyes. 10,000+ files all shot with multiple 5D's over the course of years. What does that mean? many, many duplicate file names!
    FCPX as well all know irritatingly imports XML's as new Events, not into existing ones. This obviously takes a lot of burden off media management because with a new Event comes a new database referencing its own version of the raw media. All well and good, and I'm betting its starting to click for some if you advanced users where I'm finally going with this. So I have 50 or so XMLs to bring in, all done no problem. Now I want to replicate that singular Event like I did with the Compound Clip test and have it all in one place to be my master as extensive logging begins for easy searching once editing begins. Highlight the Events, click Merge Events. NOPE. I get a new "Kill Yourself Now" error (a term I coined for Out of Memory and General Error messages in FCP Legacy meaning there ain't much you can do about it): "Two or more files have the same name. Change the names and try again, because I don't know what the **** to do with them." Ok I made up that last part but that's basically what it's saying. Just take the variable out of the equation, this happens with every which way you could try to get the clips together. Merge Events, dragging events on top of each other, dragging just the Multicam clip alone, nothing gets passed that message. What's worse is that while Batch Renaming seems like a solution, the renames do not populate inside the created clips and there is no way to Batch Rename those. Renaming everything at the finder level isn't so great because then I'd have to resync and theres an offline/online thing going here where the film has to be reconformed eventually.
    Basically, I've found that FCPX handles media management in completely different ways depending on whether you are importing into one Event yourself or doing essentially what is a new import with FCPX moving or merging Events. If you bring in all the media to one Event, on a macro level FCPX goes through file by file making aliases referencing the master file. If it hits a duplicate, it makes a parenthesis counter, and keeps going. And with the genius of FCPX metadata, that file name doesn't even matter, you can change it at the Finder level and FCPX will keep the link intact. BUT for some reason if you try to do this outside the realm of a single Event and combine files after the fact a different process takes over in creating this database system and can't handle the duplicates. I can't totally figure the reason other than it probably is scared to change the originally referenced alias to something else (which it shouldn't be scared of since Merge Events deletes the original anyway).
    This is where it gets INSANE and where I lose all understanding of what is going on, and believe me it was a delicate understanding to begin with. It comes in to play with the work around I figured out. I make the master Event with the 10,000+ clips. Then I import all the XMLs as dedicated Events. Now, I then drag the Multicam clips into the master Event, it WORKS! just takes it, no "Kill Yourself Now" error. Stranger still, now with the switched referenced Event, it even takes into account which aliased duplicate file name it's referencing in the Original Media folder. Somehow, it's taking into account the original file path and saying "Ok, I see 5 instances of MVI_5834.mov. Based on the original file path or maybe creation date or god knows what, it must be MVI_5834 (fcp3).mov." It connects perfectly. I can even remove the old XML imported Event with no problem. Crazier yet, I can now move those again to the dedicated Event I wanted originally that only contains those Multicam or Compound Clips.
    So instead of going straight from A to C, going from A to B to C works even though that actually seems way more complicated. Why can't FCPX handle Merge Events and dragging clips the same way it handles media imported into a single Event. And weirder still, why can't FCPX handle the (fcp1,2,3...) appending in the same scenario. But if the appended links are already there, No Problem. And for the love of god, it'd be nice to important XML's into existing Events and make the correct referencing happen right from the get go, which is really the source of all the above headache. I'd have no problem helping FCPX with a little manual pointing in the right direction just like any other NLE needs.
    Ok, having said all of that crap above, my question is, have I missed something completely simple I should have done instead? Now that I have everything in place how I originally envisioned, I think I will still play around a little bit more to make sure FCPX is really going to be able to handle this project. I'm at a stage right now where going another direction is still an option, although the dare devil in me wants to make this work. Media management aside, once you start editing on a FCPX timeline, its hard to go back to anything else. Apple is going to have to figure out some way not to access to everything at all times to work fluidly or big projects like this are never going to be practical in FCPX.
    Sorry for the long confusing post....

    I'm having the exact same problem, but I know nothing of ruby scripts. I've exhausted my resources with tech support, and after literally hours of work with them it seems I now am faced with either re-rating each individual song, or pointing iTunes to each song that it can't locate. Is yours a solution that could help me? How can I find out more about Ruby Scripts? Thanks for your help, hellolylo (or anyone else who might also be able to help...)
    Kenn

  • Importing text file (with file names) into Automator.. is it possible?

    Hello all,
    I have been working with Windows Batch files for my line of work. I have a couple of file names in a text file (a column), which I want to copy from one folder of one hdd to another folder on a different hdd. I have been trying to do this kind of work with a Mac. I already know how you copy and rename files in automator (which isn't difficult, of course) but you have to 'select' the files in the finder first (with get specified items).
    But the only way i see that you can specify items is by selecting them... is there a way to import a text file with all the file names instead of selecting all the file names manually?
    or is there an AppleScript alternative which I can use to import the text file (or just copy into applescript) and run before the query's of copying and renaming the files? I am kind of new to Apple programming.
    The text file looks like this:
    image1.jpg
    image2.jpg
    etc..
    so there has to be a command to: 'goto' a specific folder as well.
    Thanks in advance!

    You can import text files, but if they are just names you will need an additional action to add the source folder path. A *Run AppleScript* action can be used, for example:
    Tested workflow:
    1) *Ask for Finder Items* {Type: files } -- choose the text file containing the names
    2) *Combine Text Files* -- this gets the text file contents
    3) *Filter Paragraphs* { return paragraphs that are not empty } -- skip blank lines
    4) *Run AppleScript* -- copy and paste the following script:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 680; height: 340px;
    color: #000000;
    background-color: #FFEE80;
    overflow: auto;"
    title="this text can be pasted into an Automator 'Run AppleScript' action">
    on run {input, parameters} -- add folder path
    add the specified folder path to a list of file names
    input: a list of text items (the file names)
    output: a list of file paths (aliases)
    set output to {}
    set SkippedItems to {} -- this will be a list of skipped items (errors)
    set SourceFolder to (choose folder with prompt "Choose the folder containing the file names") as text -- this is the folder containing the names
    repeat with AnItem in the input -- step through each name in the input
    try
    set AnItem to SourceFolder & AnItem -- add the prefix
    set the end of the output to (AnItem as alias) -- test
    on error number ErrorNumber -- oops
    set ErrorNumber to ("  (" & ErrorNumber as text) & ")" -- add the specific error number
    set the end of SkippedItems to (AnItem as text) & ErrorNumber
    end try
    end repeat
    ShowSkippedAlert for SkippedItems
    return the output -- pass the result(s) to the next action
    end run
    to ShowSkippedAlert for SkippedItems
    show an alert dialog for any items skipped, with the option to cancel the workflow
    parameters - SkippedItems [list]: the items skipped
    returns nothing
    if SkippedItems is not {} then
    set {AlertText, TheCount} to {"Error with AppleScript action", count SkippedItems}
    if TheCount is greater than 1 then
    set theMessage to (TheCount as text) & space & " items were skipped:"
    else
    set theMessage to "1 " & " item was skipped:"
    end if
    set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
    set {SkippedItems, AppleScript's text item delimiters} to {SkippedItems as text, TempTID}
    if button returned of (display alert AlertText message (theMessage & return & SkippedItems) ¬
    alternate button "Cancel" default button "OK") is "Cancel" then error number -128
    end if
    return
    end ShowSkippedAlert
    </pre>
    5) *Copy Finder Items* { To: _your external drive_ }

  • How can I auto export a PDF File using the "Smallest File Size" preset and set the Exported File Name based on information from an Imported PDF?

    Greetings all,
    I am trying to create a script to automate a PDF export process for my company for inDesign. I’m fairly new to inDesign itself and have no previous experience with javascript, although I did take C++ in high school and have found it helpful in putting this code together.
    We have an inDesign template file and then use the Multi-page PDF importer script to import PDF files. We then have to export two version of each file that we import, then delete the imported file and all of the pages to reset the template. This has to be done for nearly 1000 pdf files each month and is quite tedious. I’m working on automating the process as much as possible. I’ve managed to piece together code that will cleanup the file much quicker and am now trying to automate the PDF exports themselves.
    The files are sent to us as “TRUGLY#####_Client” and need to be exported as “POP#####_Client_Date-Range_North/South.pdf”
    For example, TRUGLY12345_Client needs to be exported as POP12345_Client_Mar01-Mar31_North and POP12345_Client_Mar01-Mar31_South.
    There are two templates built into the template file for the north and south file that are toggled easily via layer visibility switches. I need to get a code that can ideally read the #s from the imported Trugly file as well as the Client and input those into variables to use when exporting. The date range is found in the same place in the top right of each pdf file. I am not sure if this can be read somehow or if it will have to be input manually. I can put North or South into the file name based on which template layer is visible.
    I am not sure how to go about doing this. I did find the following code for exporting to PDF with preset but it requires me to select a preset and then type the full file name. How can I set it to automatically use the “Smallest File Size” preset without prompting me to choose and then automatically input some or preferably all of the file name automatically? (If the entire filename is possible then I don’t even want a prompt to appear so it will be fully automated!)
    PDF Export Code (Originally from here: Simple PDF Export with Preset selection | IndiSnip [InDesign® Snippets]):
    var myPresets = app.pdfExportPresets.everyItem().name;
    myPresets.unshift("- Select Preset -");
    var myWin = new Window('dialog', 'PDF Export Presets');
    myWin.orientation = 'row';
    with(myWin){
        myWin.sText = add('statictext', undefined, 'Select PDF Export preset:');
        myWin.myPDFExport = add('dropdownlist',undefined,undefined,{items:myPresets});
        myWin.myPDFExport.selection = 0;
        myWin.btnOK = add('button', undefined, 'OK');
    myWin.center();
    var myWindow = myWin.show();
    if(myWindow == true && myWin.myPDFExport.selection.index != 0){
        var myPreset = app.pdfExportPresets.item(String(myWin.myPDFExport.selection));
        myFile = File(File.saveDialog("Save file with preset: " + myPreset.name,"PDF files: *.pdf"));
        if(myFile != null){
            app.activeDocument.exportFile(ExportFormat.PDF_TYPE, myFile, false, myPreset);
        }else{
            alert("No File selected");
    }else{
        alert("No PDF Preset selected");
    So far my code does the following:
    1) Runs the Multi-Page PDF Import Script
    2) Runs PDF Export Script Above
    3) Toggles the Template
    4) Runs #2 Again
    5) Deletes the imported PDF and all pages and toggles template again.
    It’s close and much better than the original process which was almost 100% manual but I’d like to remove the Preset prompt from the PDF script and have it automatically select the “Smallest File Size” preset. and then if there’s a way to have it auto-fill in the file name so no user input is required at all other than selecting each file to import. (If there’s a way to setup a batch action for the multi-import script that would be even better!)
    Thanks in advance and if there’s anything else I can provide that would help please let me know! Even a nudge in the right direction will be a big help!

    If you hold down the option key, it will typically show the location. Or you can often hit option-return on the file and it will reveal the file in the Finder, instead of opening it.
    Final option is to open it, and just option-click the filename in the toolbar of Preview and it should show you the location.
    It's probably an attachment to an email you've received. If you have Mail set to cache emails and their attachments it'll be stashed in a subdirectory of ~/Library/Mail. Which is fine.

  • Import From Folder: How to Extract the File Name in a Custom Column.

    Hello All
    Here´s what we´re trying to do:
    We have a folder with csv files named like this:
    Sales_2013-02-05.csv
    Sales_2013-02-04.csv
    Sales_2013-02-03.csv
    Sales_2013-02-02.csv
    Sales_2013-02-01.csv
    And in the csv files there are the sales columns but not the date column.
    So we want to extract the date from the file name.
    I´ve tried entering = Source[Name] in a custom column, but it adds a "LIST" link, and on a click on expand, it adds ALL file names from the folder in each row, instead of just the needed one.
    If we could get the proper file name in each row (from where they got extracted), we could split the column and get the date from there. But I don´t know how put the filename there properly.
    Can you help?

    This isn't entirely straightforward, but it's definitely possible. What you need to do is to apply all of your transforms to each individual file instead of the combined files. I do that as follows:
    1) Use Folder.Files as generated by the GUI to look at the list of my files.
    2) Pick one file and do all the transformations to it that I want to apply to all of the files. Sometimes, this just amounts to letting the autodetection figure out the column names and types.
    3) Go into the advanced editor and edit my code so that the transformations from step 2 are applied to all files. This involves creating a new function and then applying that function to the content in each row.
    4) Expand the tables created in step 3.
    As an example, I have some files with names that match the ones you suggested. After steps 1 + 2, my query looks like the following:
    let
        Source = Folder.Files("d:\testdata\files"),
        #"d:\testdata\files\_Sales_2013-02-01 csv" = Source{[#"Folder Path"="d:\testdata\files\",Name="Sales_2013-02-01.csv"]}[Content],
        #"Imported CSV" = Csv.Document(#"d:\testdata\files\_Sales_2013-02-01 csv",null,",",null,1252),
        #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
        #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
    in
        #"Changed Type"
    For step 3, I need to take steps 3-5 of my query and convert them into a function. As a check, I can apply that function to the same file that I chose in step 2. The result looks like this:
    let
        Source = Folder.Files("d:\testdata\files"),
        Loader = (file) =>
            let
                #"Imported CSV" = Csv.Document(file,null,",",null,1252),
                #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
                #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
            in
                #"Changed Type",
        #"d:\testdata\files\_Sales_2013-02-01 csv" = Source{[#"Folder Path"="d:\testdata\files\",Name="Sales_2013-02-01.csv"]}[Content],
        Loaded = Loader(#"d:\testdata\files\_Sales_2013-02-01 csv")
    in
        Loaded
    Now I apply the same function to all of the rows, transforming the existing "Content" column into a new value:
    let
        Source = Folder.Files("d:\testdata\files"),
        Loader = (file) =>
            let
                #"Imported CSV" = Csv.Document(file,null,",",null,1252),
                #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
                #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
            in
                #"Changed Type",
        Transformed = Table.TransformColumns(Source, {"Content", Loader})
    in
        Transformed
    Finally, I need to expand out the columns in the table, which I can do by clicking on the expand icon next to the Content column header. The resulting query looks like this:
    let
        Source = Folder.Files("d:\testdata\files"),
        Loader = (file) =>
            let
                #"Imported CSV" = Csv.Document(file,null,",",null,1252),
                #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
                #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
            in
                #"Changed Type",
        Transformed = Table.TransformColumns(Source, {"Content", Loader}),
        #"Expand Content" = Table.ExpandTableColumn(Transformed, "Content", {"One", "Two", "Three"}, {"Content.One", "Content.Two", "Content.Three"})
    in
        #"Expand Content"
    From here, you should be able to get to what you want.

  • Identifying text file names and importing on single Excel sheet

    Hey!
    Does anybody can help me with Excel VBA macro code in order to import data from text files into single Excel spread sheet? I want to create User Form where user can select start and end date of interest and macro code will import
    bunch of text files depending on user demands...
    My text files are named: 20130619004948DataLog.txt (meaning: yyyy mm dd hh mm ss). Text file contains recordings for each 15 seconds... It would be great to omit time tail (meaning that user can only specify date). Text files for one day of interest (I have
    text files covering whole year):
    20130619004948DataLog.txt
    20130619014948DataLog.txt
    20130619024948DataLog.txt
    20130619034948DataLog.txt
    20130619044948DataLog.txt
    20130619054948DataLog.txt
    20130619064948DataLog.txt
    20130619074948DataLog.txt
    20130619084948DataLog.txt
    20130619094948DataLog.txt
    20130619104948DataLog.txt
    20130619114948DataLog.txt
    20130619124948DataLog.txt
    20130619134948DataLog.txt
    20130619144948DataLog.txt
    20130619154948DataLog.txt
    20130619164948DataLog.txt
    20130619174948DataLog.txt
    20130619184948DataLog.txt
    20130619194948DataLog.txt
    20130619204948DataLog.txt
    20130619214948DataLog.txt
    20130619224948DataLog.txt
    20130619234948DataLog.txt
    Option Explicit
    Sub SearchFiles()
    Dim file As Variant
    Dim x As Integer
    Dim myWB As Workbook
    Dim WB As Workbook
    Dim newWS As Worksheet
    Dim L As Long, t As Long, i As Long
    Dim StartDateL As String
    Dim EndDateL As String
    Dim bool As Boolean
    bool = False ' to check if other versions are present
    StartDateL = Format(Calendar1, "yyyymmdd")
    EndDateL = Format(Calendar2, "yyyymmdd")
    ' I am using Userform asking user to select the date and time range of interet,
    ' However, I want to use only the date to filter the files having the name with that particular date
    file = Dir("c:\myfolder\") ' folder with all text files
    ' I need assistance with the following part:
    '1) How to filter and select the files between StartDateL and EndDateL_
    '(including files with that dates as well)?
    While (file <> "")
    If InStr(file, StartDateL) > 0 Then 'Not sure if the statements inside parenthesis is correct
    bool = True
    GoTo Line1:
    End If
    file = Dir
    Wend
    Line1:
    If Not bool Then
    file = "c:\myfolder\20130115033100DataLog.txt" 'Just for a test that the code works as intended
    End If
    'This part for the selected text files to be loaded on a single Excel Sheet.
    Set myWB = ThisWorkbook
    Set newWS = Sheets(1)
    L = myWB.Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
    t = 1
    For x = 1 To UBound(file)
    Workbooks.OpenText Filename:=file(x), DataType:=xlDelimited, Tab:=True, Semicolon:=True, Space:=False, Comma:=False
    Set WB = ActiveWorkbook
    WB.Sheets(1).UsedRange.Copy newWS.Cells(t, 2)
    t = myWB.Sheets(1).Cells(Rows.Count, "B").End(xlUp).Row + 1
    WB.Close False
    Next
    myWB.Sheets(1).Columns(1).Delete
    Application.ScreenUpdating = False
    Rows("1:1").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    End Sub

    - Make a new Excel file
    - Open the VBA editor
    - Add a Userform
    - Place 2 text boxes and 1 command button on that form
    - Paste all code below into the code module of the form
    - Download this file:
    https://dl.dropboxusercontent.com/u/35239054/FileSearch.cls
    - In the VBA editor press CTRL-M and import that file
    - Save the Excel file in the directory that contain your text files
    - Run the form
    You can format the columns of the sheet as you like, e.g. column E:H should be a number with 5 decimal places. The top row can contain some headings. My code did not affect the formatting or the headings.
    Andreas.
    Option Explicit
    Private Sub UserForm_Initialize()
    'Just a sample
    Me.TextBox1.Value = FormatDateTime(Now, vbGeneralDate)
    Me.TextBox2.Value = FormatDateTime(Now, vbShortDate)
    End Sub
    Private Sub CommandButton1_Click()
    Dim StartDate As Date, EndDate As Date
    Dim FS As New FileSearch
    Dim R As Range
    Dim ThisFile As Variant
    Dim ThisDate As Date
    Dim Data As Variant
    Dim Count As Long
    'Be sure we have 2 dates
    If Not IsDate(Me.TextBox1.Value) Then
    Me.TextBox1.SetFocus
    MsgBox "No start date"
    Exit Sub
    End If
    If Not IsDate(Me.TextBox2.Value) Then
    Me.TextBox2.SetFocus
    MsgBox "No end date"
    Exit Sub
    End If
    'Convert to real dates
    StartDate = CDate(Me.TextBox1.Value)
    EndDate = CDate(Me.TextBox2.Value)
    'Time part given?
    If Fix(EndDate) = EndDate Then
    'No include all files for this day
    EndDate = EndDate + TimeSerial(23, 59, 59)
    End If
    'Correct order?
    If StartDate > EndDate Then
    ThisDate = EndDate
    EndDate = StartDate
    StartDate = ThisDate
    End If
    With FS
    'Same path as our file
    .LookIn = ThisWorkbook.Path
    .FileName = "*DataLog.txt"
    'Search all files sort by file name
    If .Execute(msoSortByFileName, msoSortOrderAscending) = 0 Then
    MsgBox "No data files found in " & .LookIn
    Exit Sub
    End If
    'Clear previous data
    Set R = Range("A2").CurrentRegion
    If R.Row < 2 Then Set R = R.Offset(1)
    R.ClearContents
    'Show the user that we are working
    Application.Cursor = xlWait
    DoEvents
    For Each ThisFile In .FoundFiles
    'Get the date from the file name
    ThisDate = Filename2Date(ThisFile)
    'Between our dates?
    If (ThisDate >= StartDate) And (ThisDate <= EndDate) Then
    'Import at the end of the data
    Set R = Range("A" & Rows.Count).End(xlUp).Offset(1)
    Data = ReadCSV(ThisFile)
    R.Resize(UBound(Data) + 1, UBound(Data, 2) + 1) = Data
    Count = Count + 1
    End If
    Next
    End With
    'Done
    Application.Cursor = xlDefault
    If Count = 0 Then
    MsgBox "No files match your dates"
    Else
    MsgBox Count & " files imported"
    'Hide the form
    Me.Hide
    End If
    End Sub
    Private Function Filename2Date(ByVal Fullname As String) As Date
    'Convert e.g "C:\20130601142648DataLog.txt" to the date "01.06.2013 14:26:48"
    Dim i As Long, j As Long
    i = InStrRev(Fullname, "\")
    If i > 0 Then Fullname = Mid(Fullname, i + 1)
    Fullname = JustNumbers(Fullname)
    If Len(Fullname) <> 14 Then Exit Function
    Filename2Date = _
    DateSerial(Mid(Fullname, 1, 4), Mid(Fullname, 5, 2), Mid(Fullname, 7, 2)) + _
    TimeSerial(Mid(Fullname, 9, 2), Mid(Fullname, 11, 2), Mid(Fullname, 13, 2))
    End Function
    Private Function JustNumbers(ByVal What As String) As String
    'Return only numbers from What (by Rick Rothstein)
    Dim i As Long, j As Long, Digit As String
    For i = 1 To Len(What)
    Digit = Mid$(What, i, 1)
    If Digit Like "#" Then
    j = j + 1
    Mid$(What, j, 1) = Digit
    End If
    Next
    JustNumbers = Left$(What, j)
    End Function
    Private Function ReadCSV(ByVal Fullname As String) As Variant
    'Read a CSV file into an array
    Const LDelim = vbCrLf 'Line delimiter
    Const FDelim = ";" 'Field delimiter
    Dim hFile As Integer
    Dim Buffer As String
    Dim Lines, Line, Data
    Dim i As Long, j As Long
    'Be sure the file exists
    If Dir(Fullname) = "" Then Exit Function
    'Open and read all data
    hFile = FreeFile
    Open Fullname For Binary Access Read As #hFile
    Buffer = Space(LOF(hFile))
    Get #hFile, , Buffer
    Close #hFile
    'Split into lines
    Lines = Split(Buffer, LDelim)
    'Split the first line and prepare the output
    'Note: I assume that all lines have the same number of fields
    Line = Split(Lines(0), FDelim)
    ReDim Data(0 To UBound(Lines), 0 To UBound(Line))
    For i = 0 To UBound(Lines)
    Line = Split(Lines(i), FDelim)
    For j = 0 To UBound(Line)
    'Parse the fields
    If IsDate(Line(j)) Then
    Data(i, j) = CDate(Line(j))
    ElseIf IsNumeric(Line(j)) Then
    Data(i, j) = CDbl(Line(j))
    Else
    Data(i, j) = Line(j)
    End If
    Next
    Next
    ReadCSV = Data
    End Function

  • I imported files from an external hard drive to Itunes on a new computer.  they imported & play fine, but the ratings & playlists are gone & i am unable to update any info.  I found a file name playlist on old drive & imported now most files are missing!

    I imported files from an external hard drive to Itunes on a new computer.  they imported & play fine, but the ratings & playlists are gone & i am unable to update any info.  I found a file name playlist on old drive & imported now most files are missing!  Help!

    Can you locate the iTunes Library.itl file on the old drive? Ideally you would have simply copied over the entire iTunes folder structure from <User's Music> on the old computer into <User's Music> on the new one to transfer the library will all playlists, ratings, play counts etc. intact.
    tt2

  • How to import MP3 with file name into library, rather than tag?

    I've been given a CD with about 200 MP3s of lectures. They are to be listened to in order, and the file names reflect the order number, like "lecture 1", "lecture 2", etc. However, when I drag them all into iTunes, the names in the iTunes library don't include the file names - they are simply "lecture", which I guess must come from a tag in the MP3 file. So iTunes is ignoring the file name and thus I end up with 200 entries in my iTunes library that can't be ordered properly. How can I get it to use the file name when importing?
    Mike

    If you have your iTunes preferences set to keep your iTunes Music folder organized, it's possible that even the file names have changed according to the files' tags. In that case, you'll need to (at least temporarily) disable this option and import the files from your CD again.
    Once you're sure the files have been successfully added to your iTunes library and the file names kept intact, you can use the Filenames to Song Names script from Doug's AppleScripts for iTunes.
    This should get everything sorted out.

Maybe you are looking for