How to change a file that used to be a directory back to directory on linux?

9.3k views Asked by At

I was playing around with Apache VFS API to move files back and forth between my local machine and remote linux host over sftp and it converted some directories to files somehow on my linux host from drw-r----- to -rw-r-----

Does anyone know how to convert it back to a directory?

3

There are 3 answers

1
Edwin Buck On BEST ANSWER

You have to remove the file and then make a directory containing the file's original name.

The problem is not that a directory was converted to a file, the problem was that a directory was deleted, and a file of the same name was created.

0
AlexR On

Remove and create again:

rm foo
mkdir foo

Anyway if former directory is now file it is empty. In this case it is not a problem to re-create it.

0
extraneon On

You can't convert a file to a directory. You can remove the file and create a directory with the same name.

Is there something strange with the changed directories?