I have many files that i want to move into folders, their names are something like this dir1/dir2/dir3/name_of_file.ex
and then maybe another is called /dir4/name_of_file2.xe
Is there anyway of moving those files into the directory dir1/dir2/dir3
and change the name of it to only name_of_file.ex
automatically?
I really don't know how i can explain it easier.. but i have almost a 1000 files with names like TSData\Res\Catalog\Scripts\deckfoundations.txt
and TSBin\Sims2.exe
and what i want to do with those files is to move into the folder TSData\Res\Catalog\Scripts\
and then rename the file to only deckfoundations.txt
. don't know if you know PHP but there you have a explode function where you explode the name of the file with a character
$ar = end(explode("/", $filename));
print_r($ar);
would output something like this
Array
(
[0] => TSData\Res\Catalog\Scripts
[1] => deckfoundations.txt
)
Then with that i could use the first row to create the folder if not existing and then rename the full $filename to the second row of $ar