I want to move all my drupal files in www folder to html folder. I don't know how to do this in terminal and I'm not sure if all folder and files including hidden ones are drupal in the www folder, is there a way of checking the lesser obvious ones or would www have been empty before and any hidden files will auto recreate?

3 Answers 3


With zsh:

mv -- *(D) html

mv will complain that it can't move html to itself, but will still move the rest.

With bash:

shopt -s dotglob
mv -- * html

With ksh93:

mv -- * html


mv -- * .??* .[!.] html


mv -- * .[!.]* ..?* html

(you're likely to get errors for those of the patterns that have no match. That should be harmless but will still cause the exit status to be non-zero so in script you would not be able to distinguish that with a failure to move files).

  • Oh I wish I had seen this before- very helpful. I ended up uploading to html directory a fresh install and now the other is still residing other folder so I will just remove what I know to be drupal I guess. Thanks. I will copy this above info for future ref.
    – freja
    Nov 30, 2012 at 8:46

The easy way:

# from the www directory
cd ..
mv www html
mkdir www
mv html www/

This assumes you don't already have a html directory at the same level as www. If you do, pick a different name:

cd ..
mv www temp_name
mkdir www
mv temp_name www/html
  • 1
    remember to check access permissions and ownership if you're to recreate a directory that existed before. Nov 30, 2012 at 21:30

A naive option (don't try it!) would be: mv * .* html - this will however try to move . and .. too, which is not quite what you want. I usually do something like mv * .??* html - this moves normal file and hidden files with names that have at least 3 characters in them, effectively skipping . and ..

  • That would skip .a and .z as well. Nov 30, 2012 at 7:41
  • Thanks but how do I know what files are assoc with drupal, is there a way to ask the system?
    – freja
    Nov 30, 2012 at 8:47

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.