1

Here are the steps I took:

cd ~

nano .bash_profile

alias dtcl='cd ~/Desktop; mv * Desktop\ Cleanup'

Ctrl - X

Y

Save

If I run dtcl, it totally works. It moves everything from the desktop into a new folder called Desktop Cleanup, which is exactly what I wanted it to do, however, terminal gives me the following output as well:

mv: rename Desktop Cleanup to Desktop Cleanup/Desktop Cleanup: Invalid argument

Since I'm already in the folder where I want to create the directory, which doesn't already exist, why would it think I was trying to create a folder inside of a folder?

Just curious, thanks!

1

It looks like you're trying to move everything in the Desktop folder into another folder that's inside the Desktop folder. Essentially, you're trying to move the folder "Desktop Cleanup" into itself (since it's located in Desktop), and that is illegal.

Move "Desktop Cleanup" somewhere else, or use a regex that grabs all files but that folder.

  • Looks like this was easy peasy: alias dtcl='mkdir ~/Desktop\ Cleanup; mv ~/Desktop/* ~/Desktop\ Cleanup; mv ~/Desktop\ Cleanup ~/Desktop' – nuclearsalt May 9 '14 at 23:11
1

With bash, you can do this:

shopt -s extglob
mv !("Desktop Cleanup") "Desktop Cleanup"

Move everything that's not Desktop\ Cleanup to that directory.

0

As stated by Traveling Tech Guy you are trying to move "Desktop Cleanup" into itself. Moreover you need not to make current the directory from which you want to move the files.

If you don't want to change the position of "Desktop Cleanup" directory, you can suppress the error echo on the terminal with 2>/dev/null You can modify your alias in the following way

alias dtcl='mv ~/Desktop/* Desktop\ Cleanup 2>/dev/null'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.