Cross and copy files to the new structure

Hello people!

I had a huge task I'd like to simplify with a bit of Applescript.

Basically, I would like to move or copy a lot of files in a new folder structure.

I have a few different folders with all 500-4000 jpg, see image below.

First picture shows the old structure, 2nd picture show the new structure I would accomplish.

I want to do is have a script to loop through and take the first 4 characters of the file name and create a folder with that name in the location of my choice.

Then, create a new folder in the parent called JPEG folder and copy all of the files with the same name specific to this folder.

So far, I've been able to automate the creation of folders and subfolders.

any help is appreciated

loc to choose a folder "choose the Parent folder location."

Repeat with I from 1 to 3

the value d to text - via -1 of 2 ("51" & I as text)

Try

tell application "Finder" to set targetFolder to create a new folder in loc with properties {name: "61" & j}

tell application "Finder" to create a new folder to targetFolder with properties {name: "JPEG"}

tell application "Finder" to create a new folder to targetFolder with properties {name: "PSD"}

     end try

end Repeat

Hello

You could try the AppleScript script which is a simple bash script wrapper.

It will allow you to choose the source directories and destination and then analyze the source for jpeg files tree and copy the jpeg file with name starting with excatly 4 digits IJKL to the correspondent-I000/IJKL directory in the destination. In the destination path directories are created as it should. For example, your screenshots, you can choose the folder '7000-8000' or its parent directory in the source directory and the "OBJECTS" folder as the destination directory.

Any jpeg file which doesn't have a name starting with exactly 4 digits is ignored. Verbose output of the CP (1) and any errors will appear in the result pane / window (Apple Apple) Script Editor.

--APPLESCRIPT
set src to (choose folder with prompt "Choose source folder where source tree is rooted at")'s POSIX path
set dst to (choose folder with prompt "Choose destination folder where destination tree is rooted at")'s POSIX path
if dst starts with src then error "Source tree may not contain destination." number 8000
set args to ""
repeat with a in {src, dst}
    set args to args & a's quoted form & space
end repeat

do shell script "/bin/bash -s <<'EOF' - " & args & "
SRC=${1%/}
DST=${2%/}
{
export LC_CTYPE=UTF-8
while IFS= read -r -d $'\\0' f
do
    n=${f##*/}
    [[ $n =~ ^(([0-9])[0-9]{3})[^0-9] ]] || continue
    p=${BASH_REMATCH[1]}
    q=${BASH_REMATCH[2]}
   
    jpg=${DST}/-${q}000/${p}/JPEG
    psd=${DST}/-${q}000/${p}/PSD
    [[ -d $jpg ]] || mkdir -p \"$jpg\" || continue
    [[ -d $psd ]] || mkdir -p \"$psd\" || continue
   
    cp -v -pPR \"$f\" \"$jpg\"
done < <(find \"$SRC\" -type f -iname '*.jpg' -print0)
} 2>&1
exit 0
EOF"
--END OF APPLESCRIPT

Briefly tested under OS X 10.6.8 but no guarantee of any kind. Please make sure that you have a full backup of the original directories before running this kind of script.

Good luck

H

Tags: Mac OS & System Software

Similar Questions

  • Project Manager hangs during fired fresh files and copy them to the new location

    Hello

    Any project I have which includes a .mts file captured with a Panasonic GH1 camera causes the project manager in Premiere Pro (CC 2015 edition) to hang (several minutes and ends by hangs) when I do a "collect files and copy them to a new location. It creates a "xxxx. MTSBDMV' with a 'STREAM' record fo RL first file, but that is it. I can even reproduce with a new project with a single sequence, single clip.

    I'm under Premiere Pro CC 2015 edition on a Windows 10 machine. (I tried before 2014 CC edition WIndows 7 as well, same result, but I have not created a test case).

    An example of project (1,3 Mo) can be found at: Test_GH1_footage_collect_files_crash.zip - Google Drive

    Any suggestion for a solution or workaround are much appreciated.

    Thanks in advance,

    Arjan Mels

    Hi Albion,

    Thanks for your message and anxiety. I downloaded your sample project and media and was able to replicate your issue.

    Any project I have which includes a .mts file captured with a Panasonic GH1 camera causes the project manager in Premiere Pro (CC 2015 edition) to hang (several minutes and ends by hangs) when I do a "collect files and copy them to a new location. It creates a "xxxx. MTSBDMV' with a 'STREAM' record fo RL first file, but that is it. I can even reproduce with a new project with a single sequence, single clip.

    I don't know why these images give you so much trouble, but there are a few things to check.

    1. Where is the folder for multimedia file structure? All I see is the raw. Clip of MTS.
    2. In general, you copy all the SD card to your computer HD, then ingest via the media browser
      1. This allows all the metadata to clips to be implemented with the clip.
      2. The clip needs this metadata so that it works normally.
      3. Many publishers of band on the metadata by choosing File > import and do not ingest correctly via the media browser

    I suspect that this could be at the heart of your problems. You could try a try and ingest the images correctly, so try and move the project with the project manager. If it still does not work, please file a bug herereport.

    Once I transcoded your footage to ProRes LT using Adobe prelude, I could ingest images, create a sequence, then moved the sequence and associated media without problem.

    Thank you

    Kevin

  • Cannot "import and copy it to the new location" when imported into another catalog

    I have only one LR Master catalog on my desktop computer (Mac Pro). When I shoot on location, I use my laptop (MacBookPro retina), with an external HD which stores a temporary catalog of 'Place' LR and photos. Both machines run the Mavericks. When I go home, I connect the external drive 'place' to my desktop, choose "Import an another catalog" and navigate to the catalog 'Place' on the external HD normally I have the option "import and copy to a new location, so that the new originals are moved to my master of library of images on an internal HD dedicated in the MacPro. After the upgrade to 5.6 LR, I no longer get this option in the dialog box. What Miss me? I've done this dozens of times without problem.Click image for larger version.   Name: Import_from_Catalog_“2014_Tonga”.jpg  Views: 0  Size: 83.3 KB  ID: 5085

    There is plenty of space to move the originals to another destination.

    Sorry - Here's the screenshot for this forum...

    In addition, it seems that I solved the problem by starting the 'Place' of the HD catalogue externally while connected to desktop MacPro and its closure. After that, the option 'Import and copy to a new location' appeared. Don't know why this time did not differ many other times I did it, but at least it's fixed!

  • How to back up and restore the system and program files to install new OS

    Hey all,.

    I recently bought a new Toshiba 1 TB HARD drive. My old WD 1 TB HARD drive was giving me the end. occasionally, I get the BSOD. In addition, on occasion, when I restart the computer it automatically runs chkdsk program and reported several bad clusters. However the chkdsk program never seems to report the bad clusters, so periodically, when I restart, it runs and bring back them again.

    I would like to the image or to back up all the files on my HARD drive problem, then do a fresh install of Win 7 Ultimate 64 bit (my current operating system) to the new HARD disk, and then restore the clone or image system and program files on the new HARD drive. I don't want to go through the process of reinstall all again, when everything seems to work very well. Given that the image of Win 7 program makes and accurate picture of the HARD drive, then use this program would cause the new installation of Win 7 Ultimate 64 bit to be replaced by the restoration of the image. Therefore, if there should be corrupted data under a bad cluster of old HARD drive, that data would not be transferred and my existing problem would be transferred to the new HARD drive.

    On the other hand, if I do a clone of disc, I'm not sure that existing programs would continue to operate on the new HARD drive and would require a new install of each program based on the new installation of the operating system Win 7! I would have then lost my time to make a transfer of program/data files to my newly formatted and freshly installed OS.

    Anyone know of any program (Acronis True Image, Paragon, Norton Ghost, Macrium Reflect, etc) that will allow you to image or clone the program and data (including the operational needs of the files such as: Win32 system files, files of activation, etc.) so that they will work properly on the new installation of the operating system?

    Any help would be greatly appreciated. Have a great day.

    Ed Wood

    "Questionable" disk formatting can hide bad sectors or replaces the original format.  It is not known if / when bad sectors could / will reappear.

    If you have a player that you suspect problems, find advanced manufacturer of the car diagnostic tools.  Go to WD wdc.com website and get their diagnostic tools Data LifeGuard, to 'really' to test your drive.

  • My computer crashed and after the purchase of another, I used the Migration Wizard to copy all the files to the new computer.  Everything was going well until I tried to launch LR6.  It was two weeks ago and a search for many pages of the Adobe Web site. 

    My computer crashed and after the purchase of another, I used the Migration Wizard to copy all the files to the new computer.  Everything was going well until I tried to launch LR6.  It was two weeks ago and a search for many pages of the Adobe Web site.  I think I've exhausted all the remedies listed without success codes error A12E5 to questions cloud creative, Manager of Application and error 1: Configuration problems.  I'm ready to reformat my computer and try again with Time Machine.  Help would be greatly appreciated before I waste more time on this task. Any further suggestions?

    Migration of Mac with Time Machine WILL NOT WORK with the Adobe program activations due to hidden registration files

    Sign out of your account... Uninstall... to run vacuuming...

    -non-Cloud programs, to disable the service before uninstalling

    -http://helpx.adobe.com/creative-cloud/help/install-apps.html (and uninstall)

    -using the vacuuming after uninstalling and before reinstalling is often necessary

    -https://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html

    -Restart your computer... Sign in to your account... Reinstall

  • need to upgrade 250 GB hard drive, how I transferred all my files and xps3 pro for the new hard drive without lsing all this?

    need to upgrade hdd 250 GB how I transferred all of the files and opperatting sys win xp sp3 new disk hard ad not lose any

    Hello

    You cannot transfer the operating system from one hard disk to another. But you can use the backup utility to backup data and restore it on the new hard drive.

    Reference:
    Install, reinstall, or uninstall Windows
    http://Windows.Microsoft.com/en-us/Windows/help/install-reinstall-uninstall
    How to use the backup utility to back up files and folders in Windows XP Home Edition
    http://support.Microsoft.com/kb/308422
    How to use the backup utility to back up files and folders in Windows XP Home Edition
    http://support.Microsoft.com/kb/320820
    How to use Backup to protect data and restore files and folders on your computer in Windows XP and Windows Vista
    http://support.Microsoft.com/kb/309340

  • Impossible to copy files to the Sansa Fuze using Windows 7 (drag and drop, or Windows Media Player)

    Hello

    Yesterday, I bought the Sansa Fuze and I have problems copying files to the device using either Windows Media Player (Sync) or Drag and Drop (Explorer).

    The symptoms are:

    (1) the device is recognized and available in Windows 7 (Series USB MSC - sorry don't have it with me right now)

    (2) took me to upgrade to the latest firmware, which has worked flawlessly

    (3) when I try to drag and drop a file on the device (I use Windows 7, 64-bit), it starts, but doesn't seem to calculate the size of the files or waiting time to download correctly.  It is followed by a slow progressive, until the computer crashes, resulting in a constant 100% of the CPU.  The only solution is a hard reboot

    (4) when you use Windows WM, the device is recognized, okay and the synchronization starts, but it then stops without reason.  Once again, the processor springs and requires a reboot

    (5) using the results 3 and 4 in 1-5 files being copied across, but not more.

    (6) I tried several albums and one album at a time, but cannot determine if that makes a difference.

    Help, please!

    See you soon,.

    Richard

    It may be a bug in Windows 7. But one thing to try is to go to the Device Manager (assuming that Windows 7 still has), uninstall the "rocket" (under USB controllers), and then run add hardware to find and reinstall the driver.

    Use the MTP with Windows Media Player mode, MSC mode without.

  • Moving files: I am wanting to put the existing files to a new folder, how do I create a new folder and move those file to the new folder?

    I am wanting to put the existing files to a new folder, how do I create a new folder and move those file to the new folder?

    I am wanting to put the existing files to a new folder, how do I create a new folder and move those file to the new folder?

    Hello

    Go t the location where you want to create the new folder, right-click and select new/folder. Name the folder.

    Go to where the files, select the files and then use the right mouse button to drag the files into the new folder. When you drop the file, a pop-up menu, select the Move option.

    Let us know if you have any other questions.

    Thank you for using Windows 7

    Ronnie Vernon MVP
  • Mac Mavericks. Camera raw 9.1. Camera Nikon D810. How to set the default settings of the camera profile standard (now available after downloading the camera profile and copy it into the appropriate file)? Is it possible to apply also in the pictures showe

    Oops... did not write the question where I... How to set the default settings of the camera profile standard (now available after downloading the camera profile and copy it into the appropriate file)? Is it possible to apply too in images showed in the bridge? I'm a newbie in the forums and I'm not sure how to proceed.

    You can right click and copy the settings on an image that has the right profile. Then highlight all the images that you want to edit, right click and paste the settings. On the list that is displayed, simply choose the camera calibration.

  • I downloaded red CS6 plugin and added to the contents of the package, replaced the existing files with the new without saving, now my thumbnails images RED and the color correction do not WORK! How to bring back my old file importerRed! ?? Help!

    I downloaded red CS6 plugin and added to the contents of the package, replaced the existing files with the new without saving, now my thumbnails images RED and the color correction do not WORK! How to bring back my old file importerRed! ?? Help!

    Try asking in the forum Premiere Pro seems to be an Adobe first Pro Lab

  • Moved the files to the new location and now need help

    A bit new to dreamweaver.

    CS4 Mac

    I had created a site on an external HARD drive.

    Some time ago I moved it to my internal HARD drive.

    When I went to edit today I can't open it as a website... just like the individual pages.

    When I went to use a portion of my assets, DW says that "I have to set a site before I can use any assets."

    How to redefine my site - if I have already defined it, but DW doesn't see it...?

    I hope that makes sense.  Any help is appreciated.


    Thank you.

    -Drew

    Should I create a new site and move my files to the new site?

    It's a solution VERY!

    Good job...

  • followed all the instructions to copy files in the profile directory failed

    all files named from the old profile are new profile when firefox look any of the bookmarks etc are displayed - what to do now?

    "... "'old' files appear in the new profile but are re-created after firefox starts empty.

    Sounds like Firefox cannot have been closed completely when the files have been copied, or the copy and replace files with the same name did not. Windows should have asked if you want to replace each old file with the 'copied' version, and that didn't happen to you ignored.

    Or you copied the files in the profile \Local Sattings\App Data\ folder and not the profile folder OK \App Data\ - , but that would not have re-created empty files.

  • Transfer files to the new user account [was: new user]

    We went from Windows XP forum>

    How to transfer files from the current user to a user name

    Is that what you really want to do and why?

    In particular, you want to create a user account completely new to replace an old account may be corrupt, or you want to just copy some files?

    If you want to copy the user profile, see http://windows.microsoft.com/en-us/windows/fix-corrupted-user-profile#1TC=windows-7

    If you just want to copy files from the ALICE user to user BOB,

    1. Connect you as a user with "Computer administrator" privileges (this could be ALICE, BOB or another account)
    2. Go to C:\Users\Alice\Documents, right click on desired folders or files and select copy
    3. Go to C:\Users\Bob\Documents and paste files or folders you copies

    Always use 'Copy' rather than 'move '.  After you have determined that the files were copied successfully to their new location, you can go back and delete them from the old location.

    For other than documents files, replace

    C:\Users\\Music

    C:\Users\\Pictures

    C:\Users\\Videos

    etc.

  • How to transfer the original user files to the new?

    Original title: copy of the user files

    I'm looking to copy files to a new username. I had all kinds of problems with user names in Win7. I never had a logon screen and usually went straight to my account at startup. Then I had a problem with a program that some of windows installation files were accidentally deleted and I created a new user name and the program has worked with the new user name. But when I tried to go to the original user account he wasn't there and I had to use Restore to recover.

    I would like to copy files from the original user to the new user name, (office, send documents, etc.) of course the new usename is not displayed in windows now, but the files are still on the C: drive. What should I do to get all this done? What is this problem with user names does not and why Microsoft hasn't done a thing to correct? It obviously a known issue and every issue I see on this topic on the Microsoft forums there is never a response. What is the best thing for me to do to achieve this? I would like to give thanks to the prompt if possible. Does make sense for you?

    Here you go:

    1. Logging in as an administrator account.
    2. Use Windows Explorer to open files belonging to the old profile and the new account. Both are located under the folder c:\users.
    3. Copy different files and folders from the old to the new profile folders. You will be challenged by the mechanism of the UAC (User Account Control).
  • Why finder hide Documents and office files in the home directory of the user by activating iCloud drive? What about the behavior of Time Machine backup or third-party applications?

    I'm under MacOS Sierra. I am connected to my iCloud account. I activated the option Desktop and Documents, but I did NOT activate the option optimize Mac storage, because I wanted to make sure that all my files would be available locally, just in case, I would need to work without an internet connection.

    -J' noticed there now a menu iCloud in my sidebar in the Finder, with links to Documents and desktop.

    -J' also noticed that Documents is no longer presented in my favorites in my side bar of the Finder.

    -This last suggests that files saved in 'Documents' are not saved more on my HD... but only in iCloud, which isn't what I want.

    -Then, sailing in the Finder Macintosh HD/users / 'My account' /, I noticed that my Documents and desktop folders are more visible, as if these files are not saved in my home folder most. Which raises the question: where are My Documents and files on my HD, so they are still?

    -Using a shell session in the terminal and again navigate to/Users / 'My account' /, I noticed that my Documents and desktop folders are still there. Which suggest that records and records of office reside actually still in my home folder under users, but Finder actually hide it and present them as being stored in iCloud only disc. It's very confusing.

    This raises several questions:

    -In the first place, why Apple hide Documents and office files in the directory? Why not view these folders in iCloud and directory?

    -Whence the iCloud folder or drive, reside actually on my hard drive?

    -What time Machine. Is it still back up my document files and folders?

    -What games third-party app mirroring backup of My Documents files and folders? They still work properly? (I use Livedrive backup and Sugarsync for files mirrored across several macs).

    -How can I understand that Apple is doing with my folders and files? Some users might be happy with the iCloud drive concept, without worrying about how it works, but I don't take chances, and I want to keep a good understanding about the functioning of my system.

    Could someone explain what is exactly happening?

    With office and selected Documents, access to these files are now in the iCloud Drive, not in your home folder.

    My guess would be that they do not appear in your file because it would be confusing for many people to make them in two places.

    If you want in the Favorites, open iCloud Drive and drag them in the sidebar here.

    All about iCloud drive has been saved on your Mac. With the exception of the office and the Documents, they are in ~/Library/Mobile Documents. However, if you choose optimized storage, older documents are removed from your Mac. I don't know what is "old".

    ~/Documents and ~/desktop have new metadata indicating probably Finder does not display them in a Finder window, only in iCloud drive. They are not hidden in one of the normal methods of unix.

    I have not tested Time Machine or any other backup program. The folder still exist in your directory home, and they still have all the files, I don't think that changes anything.

Maybe you are looking for