How to move all files but X to Y

It doesn't really matter if it's in the terminal or if it's a applescript but I need to know how to:
Move all files in a dictionary but a few named.

Could you pleas explain more?
If you do not understand the shell while loop, it is possible that using shell commands is a bit more dangerous than you might want to try.
The explanation:
ls -a | grep -v "X" | while read file
do
    mv "$file" "Y/"
done
ls -a will list all the files in the current working directory (including the invisible files that start with a leading period.  Thinking about this, maybe you do not want to include -a.  You could cd /path/to/the/desired/directory as a way to set your current working directory as the directory you wish to move things from
cd "/path/of/the/from/directory"
ls | grep -v "X" | while read file
do
    mv "$file" "Y/"
done
The ls command's output is piped (the vertical bar | ) into the grep command (general regular expression parser).  The -v option tells grep to throw away any lines (filenames) that match the regular expression "X".  So if the regular expression X matches all the files you do not want to move, the filenames send to the next pipe will be the files you wish to move.
The while loop will read the filenames grep has selected and invoke the mv (move) command for each file selected by grep and move them to the destination directory Y
The bigest risk is that you will execute this in the wrong directory and move the files that you need somewhere else.  OR WORSE, if "Y" is NOT a directory, and you DO NOT put a trailing / the mv could move easy file to the destination file, deleting the previous file for each file moved, so effectively deleting every file in the directory except the last one.
This is why I said if you do not understand what is going on with the shell commands, you could do damage to your system.
ls could have the /path/of/the/from/directory instead of using the cd command.  The grep command could be replaced with egrep that allows using alternate matching strings:
ls /path/of/the/from/directory | egrep -v "abc.txt|def.jpg|xyz.mp3|etc..." | while read file
do
    mv "$file" "/path/to/the/destination/directory/"  # notice the trailing slash for safety
done
Good luck.  I hope you do not destroy your system

Similar Messages

  • How to move all files from a folder for a user to a centralized folder on a core server with a GP

    Hello,
    I was curious if someone know how to move all the files of a user "local" profile on a Terminal Server to that of a centralized server where the "local" profile of like the user desktop, favorites, setting, etc are stored in the event
    the local profile on the TS become corrupt it can pull from this server...
    The problem I have is no matter what I tell users to save there files to our Y drive that is a folder that is synced
    across all 6 of our TS servers, users still store files on there desktops, so as you can imagine if one day they are on one server, then next day they could be on another and there files aren't the same.... hence the reason why I want to move all there files
    to the centralized server so when I redo the profiles from scratch on the TS server in the farm they suck files from the core server and have all of the files they are used to having.... 
    So I was curious and I've heard from some this is possible in a GP, but I'd like to move the contents of all 6 TS for
    each user or if I have to d this on  per user basis I will, just looking for a way to move the files....

    Hi Trevor,
    To move all users’ desktop to a server, we can use Folder Redirection to do this. The path for Folder Redirection is:
    [Group Policy Object Name]\User Configuration\Policies\Windows Settings\Folder Redirection
    In this situation, we can choose to redirect desktop to the root of a network file share or a folder on a network share.
    Regarding how to configure this, the following article can be referred to for more information.
    Configuring Folder Redirection
    http://technet.microsoft.com/library/cc786749.aspx
    Hope it helps.
    Best regards,
    Frank Shen

  • How to move all files to the top level folder?

    I want to move all files within a particular folder -- and all files in all sub folders -- to the top level. i.e. I want to collapse the folder structure to just one folder. Assume that there are no files with the same name.
    *Method 1*
    My first thought was to use Find:
    1. Limit Find to the particular folder.
    2. Find all files in the folder with Size > 0.
    3. Switch to List view. All files are listed.
    4. Select all files and drag to the top folder
    5. Delete all sub folders manually.
    Problem: Pages files are not found, and maybe others aren't.
    This is a simple method and I'd like to stick with it.
    *QUES 1*
    What condition should I set within Find so that I can be guaranteed of finding all files?
    *Method 2*
    It was suggested in another thread that I use Terminal to move all files to the top level, but I couldn't get it to work. And there was a problem with files that consist of bundles.
    *QUES 2*
    What is the easiest way to consolidate all files within a folder to the top level -- assume no duplicate names -- and at the same time remove all sub folders?
    Message was edited by: Guy Burns

    Thanks for the suggestion of EasyFind.
    To find all files in a certain folder I typed in *[a-z 0-9] as a Boolean search (this thread won't let me post the exact characters required by EasyFind). That should cover every file I've ever named. EasyFind came back with "11719found/12316done".
    Any idea what the missing 500 files would be? I'm hoping they are files that I don't need to know about (invisible files, system files and so on).
    Message was edited by: Guy Burns

  • How to move all files in Organizer to a network location

    I have a fairly large catalog with about 20 album categories, each with between 5 and 15 albums, totalling about 20,000 photos, all currently residing on my laptop. I need to move everything to a networked drive but can't find how in the Elements help system. Is there a quick and easy way to do this?
    Message title was edited by: Brett N

    If you have a complex folder structure, it may be best to do the backup/restore as this gives you the option of recreating the same folder structure at the destination location. If folder structure is no concern (that all files can just go to a single folder because you are using Albums instead), then the File > Copy/Move to Removable Drive command would be easiest. Just select the Move option and then choose your Network drive as the Destination Drive, use the Browse button to move the files to a specific folder on that drive.

  • How to move all files from a folder for a user to a centralized folder on a core server

    Hello,
    I'm curious if there is a batch file that can be made to move the contents that are setup like this....
    I'm having to redo a TS cluster and I'd like to make a batch file script that can be executed that moves the contents of say 'jsmith's local desktop profile @ \\NGTTS1\users\jsmith to a centralized folder on our roaming desktop profile server that saves
    all of the files for the desktops @ \\NGTFS1\users\jsmith.
    The problem I have is no matter what I tell users to save there files to our Y drive that is a folder that is synced across all 6 of our TS servers, users still store files on there desktops, so as you can imagine if one day they are on one server, then
    next day they could be on another and there files aren't the same.... hence the reason why I want to move all there files to the centralized server so when I redo the profiles from scratch on the TS server in the farm they suck files from the core server and
    have all of the files they are used to having.... 
    Now I know I can do this with a MOVE command I've just never done one to this exact.
    Hopefully someone knows the command to move all the contents of one folder on one server to the folder on a different server. I've already got the bulk of the coding done of the .bat script I just don't know this move command:
    would it be this:
    move \\NGTTS1\users\jsmith *.* \\NGTFS1\users\jsmith
    any help would be appreciated, I'm sure this is a easy command to do!
    This is the coding I have so far....
    @echo off
    color 0A
    title Moving Local Profile folder to Centralized Profile Folder on Core Server.
    :start
    echo Welcome, %USERNAME%
    echo What would you like to do?
    echo.
    echo 1. Moving Local Profile folder to Centralized Profile Folder on Core Server
    echo. 
    echo 0. Quit
    echo.
    set /p choice="Enter your choice: "
    if "%choice%"=="1" goto Move-user-profiles
    echo.
    if "%choice%"=="0" exit
    echo Invalid choice: %choice%
    echo.
    pause
    cls
    goto start
    :Move-user-profiles
    echo.
    set /p profile="Enter user profile: "
    move "\\NGTTS1\users\%profile%" *.* "\\NGTFS1\users\%profile%"
    echo moving files from local profile folder to FS1 profile server, stand-by...
    echo.
    goto cancel-special 
    :cancel-special
    set /p cancel="Type cancel to stop action: "
    if not "%cancel%"=="cancel" exit
    cls
    echo Action is cancelled.
    echo.
    pause
    exit

    In Windows we would do this using Group Policy.  There is a Policy setting that csn move the Desktop folder to any server you want to move it to.  Once set it will automatically do this for you.
    You should post in the Group Policy forum to find out how we use Group Policy to manage users profiles in Windows.
    You cannot use a script to relocate a users Desktop folder.  The desktop is locked by the time the users logon script is finished running.  It the desktop and profile are already being managed by Group Policy then this can only be done with GP.
    There are also numerous issues associated with deployment and re-deployment that you need to address  Post your questions in the Winows Deployment forum to get assistance with deployment issues.
    Again - want you are asking is not generally possible because of how Windows is designed.  This would only likely work on a simple system or on a stand alone PC and then only under a very limited set of circumstances.
    Use GP folder redirection to do this.  For deployment use Deployment Forum and for TS specific issues post in the RDS forum. 
    All of  this needs to be considered correctly for TS users inn a TS Cluster environment. (TS Cluster?? - not sure what you mean by that.
    ¯\_(ツ)_/¯

  • How to move all files, and authorisations...

    Hi.
    I have been making music on a G4 powerbook for a while, but now i have got an imac G5 20" machine ready and waiting for me.
    The powerbook is running 10.3.9 and the imac will be running the latest tiger os.
    I need to find out the most painless way of moving all my software (i have a lot of music software (logic pro, audio instruments, each with their own validation codes etc) and i need to work out how to get this over to the other mac without having to move things one by one.
    Can it be done, or do i have to do everything one app at a time?
    Many thanks
    David Tobin

    You should be able to use the Setup Assistant found in your Utilities folder without a problem.
    Apple has a description and some FAQs HERE for you.

  • How do I move all files from an old PPC to a new Mac Mini?

    How do I move all files from an old PPC to a new Mac Mini?

    The new mini has a Firewire 800 port. Likely the PPC version only has Firewire 400.  The OP will need a converter cable which is why I was asking first about what hardware is available and how much is being copied.
    Probably go with using the external hard drive if you decide all you want are data files.
    If you want to migrate:
    Kappy: A Basic Guide for Migrating to Intel-Macs - http://discussions.apple.com/message/10257343
    Mac OS X 10.3, 10.4: Transferring data with Setup Assistant / Migration Assistant FAQ - http://support.apple.com/kb/HT1554
    Setting-up a new Mac from an old one or its Backups - http://web.me.com/pondini/AppleTips/Setup.html

  • How to make Edge Animation works in HLTM5 Offline? I cache all files, but Edge didn't play.

    How to make Edge Animation works in HLTM5 Offline? I cache all files, but Edge didn't play.
    Some createJS animation start without any problem.
    Thanks!
    Astors

    Thank you for your answer.
    I do use cdn off for publish setting.
    The Web site that I am working on is a very complicated site. Edge
    animations are in a subdirectory of Apache server.
    When server is offline, I get all files from Appcache without problem,
    excepted *_EdgePreload.js.
    I Google hundreds time, cannot find answer on why this file is always get
    online.
    Finally, I find out myself, Adobe Edge don’t like relative file path for
    *_EdgePreload.js.
    Change to root absolute path fixed the problem:
    Astors

  • How to move all images from a site to a new folder and not lose links?

    I have always wondered this.....tried a few things with no success..Whenever I take over a site from someone, a lot of time the previous designer did not make folders for ANYTHING including images.....so in thier main directory they have 20 html pages, 200 images and css files etc.....I can not think this way.....I want to just make a folder for images...put all the images there.....a css folder....etc. Once I do this all my links are lost and it is to much work to replace each one with the broken link finder in Dreamweaver......In some other applications like Logic Studio ( a music production application as an example ) it is very similar. Your main song file is pointing to linked audio files all over your hard drive....If you decide you want to move that drive it will search for the linked audio files and when it can not find them it asks you to specify the new folder or search manually for them.....if I had moved 200 audio files it comes in quite handy because I can just point to that new folder and im done.......finally, my question is what would you guys recommend for doing this? Moving hundreds of image files so that I can organize things...........any help would be GREATLY appreciated...I have googled but found no great technique...

    I'm having the same or similar issue...  I think...  trying to do a little house cleaning in the file structure.  For example, in our events folder I'm creating archive folders (i.e. - 2004, 2005, ect...) and when I use the Files Panel to drag and drop the past event pages into the newly created archive folder, the pages loose all their links.
    Image link prior to and after moving are the same (../images/logo1.gif)
    It does ask me to confirm that I want to move the file but nothing about updating the links.  Is it due to the way the files are linked in the original files?
    Thanks in advance for any help!!!

  • RH8 + WinXP - Move all files after a build to version control?

    I am working with about 300 topics that are built into WebHelp.  Must I move all files from the WebHelp root and sub-folders to our Subversion folders after I have done a build with RH?
    From Subversion, the Help files are added "en masse" to the application.
    Can I move only those files that I've changed, if I am only changing content but I am not adding new topic files or deleting files?

    The odds of you actually identifying every, and I mean every, changed file are very low. Do yourself a favor.
    Good luck,
    Leon

  • How to move all the standard and adhoc reports from cube to multi provider

    How to move all the standard and adhoc reports from the basic cube to multi provider?
    i created this multiprovider to do the maintenence on the basic cube. for example the infocube physical partition, line item dimension and compression.
    what we decided to do is move all the Standard and ad-hoc reports from the basic cube to the multiprovider. How to do it? and make a copy of the basic cube and do the maintenence on the cube. please help.
    Thanks in advance sdn experts!

    Hi Les,
    This sounds good and one thing we try to always keep in mind when undertaking such activities is to always minimise the impact to the user and make the process as transparent to them as possible. So lets say you have your multiprovider and copied queries up in Prod, these queries will still pick up the data from the base cube.
    Now you need to make a copy of the base cube for some changes to the cube model, I would suggest that you copy the cube and make your changes on the copied cube itself. Then 9depending on the changes done) you can load data from Original Cube to New Cube. When this is being done, make sure that you change your queries to add a restriction on 0INFORPOV by Original Cube.
    After the load to the new cube is complete you can run reports restricted to each cube to verify the numbers. Then change the 0INFOPROV restriction in the queries to point to the New Cube and disengage the old cube from the multiprovider.
    Hope this helps...

  • How to select all files in a stack? Control-click doesn't work

    how to select all files in a stack? Control-click doesn't work

    Switch to list or column view. If you must use icon view, instead of Shift-clicking items, click on an empty space near one of them and drag to enclose them.
    (119467)

  • How to select all files in "user dir" (LastAccessedDirectrory) using applet

    Hi,
    Can anyone tell me " How to select all files in "user dir" (Last Accessed Directrory) using applet"?
    For this which method in applet used?
    Thanks in Advance.

    1) Do you want "user dir" (watever that is) or do you wnat the last accessed directory? Last accessed by what/whom?
    2) Applets can't access the local file sytem, and for good reason, unless they're signed and the client has given permission.

  • File Dialog - How to remove all files pattern in LV 8.x

    How to remove "all files" pattern in LV 8.x in the file dialog.
    Is it possible?
    Thanks
    Dany
    Dany Allard

    If it is a security issue, you will probably need to implement a custom dialog and actively filter for file types.  No matter what pattern you have showing, the user can type a pattern into the dialog and get anything they want.  In addition, file extension is not sufficient to determine file type.  You should probably check the file itself to ensure it is an HTML file and does not have any embedded nastiness.
    Fortunately, custom dialogs are easy to make.  Using the event structure, you can filter inputs as well, so that only HTML files will be accepted.  Good luck.  Let us know if you need more help.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • How to move PDF file from Spool to Application Server?

    How to move PDF file from Spool to Application Server?
    Cannot use RSTXPDFT4 because that converts OTF to PDF and the file is already PDF.
    RSTXPDFT5 doesn't work. It picks the file up and assigns it a 'text' type and outputs a 1 line txt (1kb in size) on the server with the spool number in it!
    The program which outputs the file to the spool, in the first place, uses adobe forms and outputs to a printer of type PDF.

    Hi Gemini ,
    Please refer the below links.
    [http://sap.ittoolbox.com/groups/technical-functional/sap-hr/convert-a-spool-to-pdf-and-save-on-application-server-in-background-720959]
    [http://www.sapfans.com/forums/viewtopic.php?f=13&t=325628&start=15]
    Edited by: Prasath Arivazhagan on Apr 13, 2010 4:48 PM

Maybe you are looking for

  • Oracle.jbo.RowCreateException: JBO-25017: Error while creating a new ROW

    I am trying same multi step PO example. I have created a search page and there are 3 other pages for PO Header, PO Line and Review/Submit Page. I am coming on 2nd page(creating Line Item) and when I click on create new item record I am getting this e

  • How do you embed a photo gallery created in adobe bridge to a webpage?

    HI, Help would be appreciated, i have created a photo gallery using adobe bridge but i am struggling in finding a way to embed the gallery to a webpage. I do not dreamweaver. Can anybody help? Many thanks

  • What is the proper method for creating a document with double spacing?

    There was a questioned posed regarding double spacing documents and it was suggested to set the leading to twice that of the font size.  Is this how "double spacing" is defined?

  • Oracle Workflow & SMS

    Hi Is there a mechanizm or documented approach to send SMS notifications from within an oracle workflow process ? I have read lot of documentations and I cannot find helpful information regarding this issue. I am thinking about using an SQL data feed

  • 27 iMac does not recognize iPad

    Just upgraded from a 24 iMac to the 27 (i7, 2.93). When I plug in my iPad it indicates "Not Charging" and is not listed in iTunes (which I have to start manually). 27 works ok with iPhone 4 and the iPad works ok on the 24. Is there a setting that I h