Need script to check for duplicate file names when copying a folder

Hello,
I am a new applescript user trying to write what I believe should be a simple script. I was planning on using the "add-new item alert" script as a template.
Basically I have people copying folders of photos into a library folder, but I don't want the Finder to copy the photo if it already exists in the library. The images in the library are organized into subfolders.
I need a script that will check all the file names in the new folder against all the file names in the library, and NOT add the new one if it already exists.
If anyone can help it would be greatly appreciated,
Thanks,
C

I have a script that "kind of" works. The only problem I've seen is that it gets confused when filenames contain characters that are fine in Macland but not good in Unixland. Forward slashes are a good example of this.
In this case I have a folder in my home named "copytest" Inside copytest are two folders:
Source (containing the images to be added)
Dest (My existing library of images)
It also assumes that the folder of images to be added contains no sub-folders. Hope this helps.
tell application "Finder"
set theSource to folder "source" of folder "copytest" of home
set imagesToBeCopied to name of every file of theSource
end tell
repeat with theFile in imagesToBeCopied
try
if (do shell script "find -r ~/copytest/dest -name " & quoted form of (theFile as string)) is not equal to "" then
--The file exists. Don't copy it
else
--the file doesn't already exist. Copy it.
end if
on error
return "Failed while trying to check for existence of a file"
end try
end repeat

Similar Messages

  • Ask for the file name when printing on XP x64

    I have just installed my CS3 on Windows XP x64. Installation was successful and all is working fine. But there are few things which are working differently and I can not find any way to fix it.
    One of the problems I have is that I can not have it so that I will be asked for the name of the PDF file created. It simply goes through and allocates name of the file used for printing. It happens for all applications i.e. Word, Excel, InDesign, Corel. In my automatic processes I realy need to be prompted for the file name / location. Is it possible to modify some settings to have it under XP x64 ??? I hope it is.
    Thanks for advise.
    Tony

    I would like to add few details which may help to find the source of the problem.
    When I will select Adobe PDF as a printer, then click on Properties and select
    Prompt for Adobe PDF filename
    in Adobe PDF Output Folder then printing starts and will not progress at all. If I will change the Adobe PDF Output Folder to local it prints OK but is not asking for the file name / destination.
    How I can have it printing and asking for the file name / destination ? Or maybe on XP x64 it is not possible at all ?
    Regards,
    Tony

  • Check for Duplicate files.

    I have multiple folders with duplicate files, i was wondering what is the best way to check for duplication based on file content even if the file name is slightly different.

    There are several commercial software options. I suggest that you use the ones that use SHA1 matching.
    Decloner is pretty good, and it comes with a 30-day trial that is FULL FEATURED.
    http://www.pixelespressoapps.com/decloner/
    Only works on snow leopard and up.
    Their website conviniently compares other duplicate file software packages.
    I purchased Twins, which is also great.
    http://www.rockysandstudio.com/apps/twins
    Only works on Lion and up.
    Remember, SHA1 is the way to go if you want to find duplicates with highest accuracy.

  • Need script to add path and file name to fillable  form

    I have a fillable pdf form that I would like to have a script that adds the path and file name to the form. This script would be in a field at the end of the document.
    I am a newbie to javascript and formcalc. The script will be the only one in the form.
    Thanks for any assistance.
    Lisa

    Hi,
    I have a sample that attach a file to the PDF and write in a text field the file name. I don´t know how to get the full path and it only works in Acrobat. To work in Adobe Reader is necessary the LC Reader Extensions to give some special permissions to the document. But, regard this, you still want the sample send me a email to [email protected]
    Best Regards,

  • Check for Correct File Name Syntax

    What is the most efficient way to check if a String can be used as a file name? Here is my current (bulky) way:
    public static boolean isValidFileName(String s) {
         try {
              File file = new File(s);
              file.mkdir();
              file.delete();
              return true;
         catch (Exception e) {
              return false;
    Thanks!

    Sorry about the poor code format, above. This is my first posting experience here.
    public static boolean isValidFileName(String s) {
         try {
              File file = new File(s);
              file.mkdir();
              file.delete();
              return true;
         catch (Exception e) {
              return false;
    }

  • Fix for "Duplicate file name was specified"

    Bonjour, impossible d'installer Itunes ..."un nom de fichié dupliqué a été spécifié"...que faire? j'ai déjà désinstaller itunes (dans le bon ordre avec ses 5 composants..." UNe solution SVP ?????merci

    Hello, can not install Itunes ... "a duplicated the File Name specified" ... what to do? I already uninstall itunes (in the correct order with 5 components ... "Please aN solution??? thank you
    Tranlated by Google
    Did you also delete the folders specified in the support document HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8?
    Avez-vous supprimez également les dossiers spécifiés dans le document d'assistance HT1923: Suppression et réinstallation d’iTunes et d’autres composants logiciels sous Windows Vista, Windows 7 ou Windows 8?
    Traduit par Google
    See also Troubleshooting issues with iTunes for Windows updates.
    tt2

  • Creating a powerhsell script to check for .ost files and delete all .ost files if there is any detected

    Hi Guys,
    I was hoping someone could help me with a PowerShell script to check a directory to see if any .ost files exist.
    If it detects any .ost files I want it to run this code:
    get-childitem "C:\Users\*" -include *.ost -recurse -force | foreach-object { remove-item $_ -force  }
    If it doesn't detect any .ost files I just want the script to exit.
    Looking to add this to our startup scripts in group policy
    Many thanks,

    Hi Tlewis4435,
    In addition, please refer to the script below:
    $files = get-childitem "D:\SHARE\*" -include *.ost -recurse -force
    if($files){ #detect files
    foreach($f in $files) { remove-item $f -force }
    else{exit} #if there is no file then exit powershell
    If there is anything else regarding this issue, please feel free to post back.
    If you have any feedback on our support, please click here.
    Best Regards,
    Anna Wang
    TechNet Community Support

  • Checking for duplicate files

    i have a full hard drive, I think that i have duplicate copies of movie files that i can't see, How do i find them?

    I used dupeGuru before after many options. it worked best for me although its a shareware.

  • Optimizing a search for duplicate files in a filesystem

    We have a large directory that people have been dumping to for years (~200k files), and I want to go through and look for duplicate files. The first part of this was just scanning through and checking for duplicate file names.  I wrote a simple VI to serarch for duplicates, but it is very inefficiant because of multiple string comparisons. Even optimized as much as I could think to do, I'm only scanning about 1k files / minute.  I have attached my code - any help would be appreciated.
    Attachments:
    search.vi ‏22 KB

    This is trivial using the variant attributes mentioned earlier.  Attached is my method which uses the Variant Repository XNode I developed.  Not sure on performance comparisions.
    EDIT:  I'm betting the thing that will take the longest will be performing the MD5, I'm sure a CRC32 could be done faster which is probably just as good in this situation, or even a sum of the bytes of the file as a quick way of identifying the file.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
    Attachments:
    Find Duplicate Files.vi ‏23 KB

  • Premiere Pro CC creates duplicate file names for recorded VO's

    When I add a voice over (VO) to my project using the audio mixed it creates an audio file in the form of Audio 2-xx.wav and it automaticly increments the xx for each new recording.  Now using the CC version of Premiere, and after trying the link to Audition CC, it starts over with duplicate file names.  The file names look the same as existing files, but the new ones have an extra space betwee the "Audio" and the "2".  How can I control the file names that Premiere assigns to new Vo recordings?

    Camtasia http://forums.adobe.com/thread/836800 may help
    -and Lagarith Codec http://forums.adobe.com/thread/1287577
    -and http://forums.adobe.com/thread/775288
    -and http://forums.adobe.com/thread/453044
    -and http://forums.adobe.com/message/3202148

  • 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

  • Check for duplicate record in SQL database before doing INSERT

    Hey guys,
           This is part powershell app doing a SQL insert. BUt my question really relates to the SQL insert. I need to do a check of the database PRIOR to doing the insert to check for duplicate records and if it exists then that record needs
    to be overwritten. I'm not sure how to accomplish this task. My back end is a SQL 2000 Server. I'm piping the data into my insert statement from a powershell FileSystemWatcher app. In my scenario here if the file dumped into a directory starts with I it gets
    written to a SQL database otherwise it gets written to an Access Table. I know silly, but thats the environment im in. haha.
    Any help is appreciated.
    Thanks in Advance
    Rich T.
    #### DEFINE WATCH FOLDERS AND DEFAULT FILE EXTENSION TO WATCH FOR ####
                $cofa_folder = '\\cpsfs001\Data_pvs\TestCofA'
                $bulk_folder = '\\cpsfs001\PVS\Subsidiary\Nolwood\McWood\POD'
                $filter = '*.tif'
                $cofa = New-Object IO.FileSystemWatcher $cofa_folder, $filter -Property @{ IncludeSubdirectories = $false; EnableRaisingEvents= $true; NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' }
                $bulk = New-Object IO.FileSystemWatcher $bulk_folder, $filter -Property @{ IncludeSubdirectories = $false; EnableRaisingEvents= $true; NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' }
    #### CERTIFICATE OF ANALYSIS AND PACKAGE SHIPPER PROCESSING ####
                Register-ObjectEvent $cofa Created -SourceIdentifier COFA/PACKAGE -Action {
           $name = $Event.SourceEventArgs.Name
           $changeType = $Event.SourceEventArgs.ChangeType
           $timeStamp = $Event.TimeGenerated
    #### CERTIFICATE OF ANALYSIS PROCESS BEGINS ####
                $test=$name.StartsWith("I")
         if ($test -eq $true) {
                $pos = $name.IndexOf(".")
           $left=$name.substring(0,$pos)
           $pos = $left.IndexOf("L")
           $tempItem=$left.substring(0,$pos)
           $lot = $left.Substring($pos + 1)
           $item=$tempItem.Substring(1)
                Write-Host "in_item_key $item in_lot_key $lot imgfilename $name in_cofa_crtdt $timestamp"  -fore green
                Out-File -FilePath c:\OutputLogs\CofA.csv -Append -InputObject "in_item_key $item in_lot_key $lot imgfilename $name in_cofa_crtdt $timestamp"
                start-sleep -s 5
                $conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=PVSNTDB33; Initial Catalog=adagecopy_daily; Integrated Security=TRUE")
                $conn.Open()
                $insert_stmt = "INSERT INTO in_cofa_pvs (in_item_key, in_lot_key, imgfileName, in_cofa_crtdt) VALUES ('$item','$lot','$name','$timestamp')"
                $cmd = $conn.CreateCommand()
                $cmd.CommandText = $insert_stmt
                $cmd.ExecuteNonQuery()
                $conn.Close()
    #### PACKAGE SHIPPER PROCESS BEGINS ####
              elseif ($test -eq $false) {
                $pos = $name.IndexOf(".")
           $left=$name.substring(0,$pos)
           $pos = $left.IndexOf("O")
           $tempItem=$left.substring(0,$pos)
           $order = $left.Substring($pos + 1)
           $shipid=$tempItem.Substring(1)
                Write-Host "so_hdr_key $order so_ship_key $shipid imgfilename $name in_cofa_crtdt $timestamp"  -fore green
                Out-File -FilePath c:\OutputLogs\PackageShipper.csv -Append -InputObject "so_hdr_key $order so_ship_key $shipid imgfilename $name in_cofa_crtdt $timestamp"
    Rich Thompson

    Hi
    Since SQL Server 2000 has been out of support, I recommend you to upgrade the SQL Server 2000 to a higher version, such as SQL Server 2005 or SQL Server 2008.
    According to your description, you can try the following methods to check duplicate record in SQL Server.
    1. You can use
    RAISERROR to check the duplicate record, if exists then RAISERROR unless insert accordingly, code block is given below:
    IF EXISTS (SELECT 1 FROM TableName AS t
    WHERE t.Column1 = @ Column1
    AND t.Column2 = @ Column2)
    BEGIN
    RAISERROR(‘Duplicate records’,18,1)
    END
    ELSE
    BEGIN
    INSERT INTO TableName (Column1, Column2, Column3)
    SELECT @ Column1, @ Column2, @ Column3
    END
    2. Also you can create UNIQUE INDEX or UNIQUE CONSTRAINT on the column of a table, when you try to INSERT a value that conflicts with the INDEX/CONSTRAINT, an exception will be thrown. 
    Add the unique index:
    CREATE UNIQUE INDEX Unique_Index_name ON TableName(ColumnName)
    Add the unique constraint:
    ALTER TABLE TableName
    ADD CONSTRAINT Unique_Contraint_Name
    UNIQUE (ColumnName)
    Thanks
    Lydia Zhang

  • Check for a file to exist

    Hi all, I have a script which returns the path for a file in this way:
    set outfile to (choose file name with prompt "Choose output file." default name "out.iso")'s POSIX path
    the path is then passed to the shell. Now, I want the script to check whether that file exists and if it does, the script needs to be stopped.
    I tried some ways I found on the web but none seems to work.
    Any help would be appreciated.
    Thank you!
    Lorenzo

    Try using:
    set outfile to (choose file name with prompt "Choose output file." default name "out.iso")'s POSIX path
    set thefile to POSIX file outfile
    tell application "Finder"
    if exists thefile then
    return --or other commands to stop script
    end if
    end tell
    (57077)

  • When I plug in my ipod it comes up with an error saying, "ipod "Skye" cannot be synced, duplicate file name specified." it wont let me put any songs on my ipod? Help!

    my computer deleted all of my songs off my ipod one time with i unplugged it, i think i unplugged it too soon and it wasn't finished ejecting. now every time i plug it in it gives me an error saying "the ipod 'Skye' cannot be synced, a duplicate file name was specified." It wont let me put any songs on my ipod now.

    Never mind.  I found out how to fix the problem
    - Go to "Computer"
    - Right click on your IPod icon
    - Click "Properties"
    - Go to the "Tools" tab
    - Under "Error -checking" cilck the "Check now..." button
    After doing all of that, ITunes now works like normal for me.

  • Every time i try to sync my iphone with my music on itunes, it says, "The iPhone "KORA" cannot be synced. A duplicate file name was specified."

    I need help

    Hi korasaurous,
    Thanks for visiting Apple Support Communities.
    You may find the troubleshooting steps in this article helpful with resolving the error message you're seeing:
    iTunes: Troubleshooting issues with third-party iTunes plug-ins
    http://support.apple.com/kb/ts3430
    There are several ways an add-on can cause iTunes to act erratically, such as those listed below:
    You see this alert while syncing: "... cannot be synced. A duplicate file name was specified."
    Best Regards,
    Jeremy

Maybe you are looking for

  • Defective t440s and the worst customer support I've ever received

    2 months ago I purchased a t440s that arrived defective. Notably, the screen was the upgraded FHD IPS panel. My unit came with the LG model, which is notorious for being defective. The screen had bad viewing angles (its main selling point...), about

  • Currency translation problem

    Dear All, I am trying to create  the currency translation type and use it in the Bex Designer. But its not converting the values at all. Output required:- Need to convert all INR values to fixed USD currency. Source currency is always INR and target

  • Inbound Proxy not working

    Hi, I have configured a proxy for a BAPI (SAP EM EventHandler.AddEventMessage02) but it does not work. EventHandler.AddEventMessage02 has a deep structure. Step by Step: ABAP Proxy generated. Activate changes Export WSDL from Proxy. Import WSDL to ES

  • There is anyway to find the tables name where data is getting inserted currently.

    Hi All, I need T-Sql Query to find list of tables in which data is getting loaded currently. Thanks Shiven:) If Answer is Helpful, Please Vote

  • ABNAN- Asset Posting Captitalization

    Dear All, I am try using ABNAN for changing the asset value. The asset was capitalized on 2013.09.08. After runing ABNAN, i enter Orig. Value date with 2014.06.08. It pops up the error message AA566.  I want to know if the Orig. Value date must be in