How to move files from one directory to a nested directory using SSH?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















I would like to know how to move all the files, not the folder or directory, to an existing folder or directory two levels down.










share|improve this question
























  • Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?

    – George M
    Feb 5 '13 at 21:02















1















I would like to know how to move all the files, not the folder or directory, to an existing folder or directory two levels down.










share|improve this question
























  • Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?

    – George M
    Feb 5 '13 at 21:02













1












1








1








I would like to know how to move all the files, not the folder or directory, to an existing folder or directory two levels down.










share|improve this question
















I would like to know how to move all the files, not the folder or directory, to an existing folder or directory two levels down.







shell rename






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 6 at 21:33









Rui F Ribeiro

39.6k1479132




39.6k1479132










asked Feb 5 '13 at 18:33









user31836user31836

61




61












  • Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?

    – George M
    Feb 5 '13 at 21:02

















  • Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?

    – George M
    Feb 5 '13 at 21:02
















Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?

– George M
Feb 5 '13 at 21:02





Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?

– George M
Feb 5 '13 at 21:02










2 Answers
2






active

oldest

votes


















1














You'll want to use the find command.



find . -type f -name "*" -print0 | xargs -0 -I mv ../backup_dir ; mv ../backup_dir ./new/directory


Note that I've moved the files to a directory to one directory up, to prevent find from being stuck in a loop finding the new files that you're moving. Then move the directory two levels down.



If you need only files in the current directory, you can use the command:



find . -type f -maxdepth 1 -name "*" -print0 | xargs -0 -I mv ../backup_dir 





share|improve this answer

























  • @uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.

    – Stephan
    Feb 5 '13 at 23:00


















0














If you have zsh available, this is pretty simple. The pattern * matches all files (including directories). To match only regular files, add the glob qualifier .. Glob qualifiers are a zsh feature.



mv *(.) existing/subsubdirectory/


(Actually * skips files whose name begins with a . (“dot files”). This is probably not a concern here, but if you do need to move those as well, add a D inside the parentheses.)






share|improve this answer























  • Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.

    – user31836
    Feb 8 '13 at 21:41










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f63835%2fhow-to-move-files-from-one-directory-to-a-nested-directory-using-ssh%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You'll want to use the find command.



find . -type f -name "*" -print0 | xargs -0 -I mv ../backup_dir ; mv ../backup_dir ./new/directory


Note that I've moved the files to a directory to one directory up, to prevent find from being stuck in a loop finding the new files that you're moving. Then move the directory two levels down.



If you need only files in the current directory, you can use the command:



find . -type f -maxdepth 1 -name "*" -print0 | xargs -0 -I mv ../backup_dir 





share|improve this answer

























  • @uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.

    – Stephan
    Feb 5 '13 at 23:00















1














You'll want to use the find command.



find . -type f -name "*" -print0 | xargs -0 -I mv ../backup_dir ; mv ../backup_dir ./new/directory


Note that I've moved the files to a directory to one directory up, to prevent find from being stuck in a loop finding the new files that you're moving. Then move the directory two levels down.



If you need only files in the current directory, you can use the command:



find . -type f -maxdepth 1 -name "*" -print0 | xargs -0 -I mv ../backup_dir 





share|improve this answer

























  • @uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.

    – Stephan
    Feb 5 '13 at 23:00













1












1








1







You'll want to use the find command.



find . -type f -name "*" -print0 | xargs -0 -I mv ../backup_dir ; mv ../backup_dir ./new/directory


Note that I've moved the files to a directory to one directory up, to prevent find from being stuck in a loop finding the new files that you're moving. Then move the directory two levels down.



If you need only files in the current directory, you can use the command:



find . -type f -maxdepth 1 -name "*" -print0 | xargs -0 -I mv ../backup_dir 





share|improve this answer















You'll want to use the find command.



find . -type f -name "*" -print0 | xargs -0 -I mv ../backup_dir ; mv ../backup_dir ./new/directory


Note that I've moved the files to a directory to one directory up, to prevent find from being stuck in a loop finding the new files that you're moving. Then move the directory two levels down.



If you need only files in the current directory, you can use the command:



find . -type f -maxdepth 1 -name "*" -print0 | xargs -0 -I mv ../backup_dir 






share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 5 '13 at 22:34









Gilles

532k12810661594




532k12810661594










answered Feb 5 '13 at 20:46









StephanStephan

1,771714




1,771714












  • @uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.

    – Stephan
    Feb 5 '13 at 23:00

















  • @uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.

    – Stephan
    Feb 5 '13 at 23:00
















@uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.

– Stephan
Feb 5 '13 at 23:00





@uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.

– Stephan
Feb 5 '13 at 23:00













0














If you have zsh available, this is pretty simple. The pattern * matches all files (including directories). To match only regular files, add the glob qualifier .. Glob qualifiers are a zsh feature.



mv *(.) existing/subsubdirectory/


(Actually * skips files whose name begins with a . (“dot files”). This is probably not a concern here, but if you do need to move those as well, add a D inside the parentheses.)






share|improve this answer























  • Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.

    – user31836
    Feb 8 '13 at 21:41















0














If you have zsh available, this is pretty simple. The pattern * matches all files (including directories). To match only regular files, add the glob qualifier .. Glob qualifiers are a zsh feature.



mv *(.) existing/subsubdirectory/


(Actually * skips files whose name begins with a . (“dot files”). This is probably not a concern here, but if you do need to move those as well, add a D inside the parentheses.)






share|improve this answer























  • Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.

    – user31836
    Feb 8 '13 at 21:41













0












0








0







If you have zsh available, this is pretty simple. The pattern * matches all files (including directories). To match only regular files, add the glob qualifier .. Glob qualifiers are a zsh feature.



mv *(.) existing/subsubdirectory/


(Actually * skips files whose name begins with a . (“dot files”). This is probably not a concern here, but if you do need to move those as well, add a D inside the parentheses.)






share|improve this answer













If you have zsh available, this is pretty simple. The pattern * matches all files (including directories). To match only regular files, add the glob qualifier .. Glob qualifiers are a zsh feature.



mv *(.) existing/subsubdirectory/


(Actually * skips files whose name begins with a . (“dot files”). This is probably not a concern here, but if you do need to move those as well, add a D inside the parentheses.)







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 6 '13 at 1:28









GillesGilles

532k12810661594




532k12810661594












  • Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.

    – user31836
    Feb 8 '13 at 21:41

















  • Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.

    – user31836
    Feb 8 '13 at 21:41
















Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.

– user31836
Feb 8 '13 at 21:41





Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.

– user31836
Feb 8 '13 at 21:41

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f63835%2fhow-to-move-files-from-one-directory-to-a-nested-directory-using-ssh%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?