Create folder from file name

Advertisement

nickodemos
Joined:
Posts:
2

Create folder from file name

Was wondering if it would be possible to have a script that would create folder based on the file name.

EG I would click on BSD.iso and choose the script to create a folder in current folder with the name BSD and move the BSD.iso into the newly created BSD folder.

I did a quick search and found nothing asking this.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
27,426
Location:
Prague, Czechia

Re: Create folder from file name

"click" in WinSCP GUI? In panel with a remote folder?

Reply with quote

nickodemos
Joined:
Posts:
2

Sorry I should have thought to put that in.

Yes. On the remote folder I would right click on a file to bring up the context menu and have an option under 'Custom File Commands' that would create a folder and move the file I clicked on into the newly created folder: root/BSD.iso >> root/BSD.iso/BSD.iso.

Only thing better would being able to remove the extension in the folder.

root/BSD.iso >> root/BSD/BSD.iso.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,426
Location:
Prague, Czechia

I'm no *nix expert, so there can be a better solution, but should should do:

filename="!" && mkdir "${filename%.*}" && mv "!" "${filename%.*}"

Reply with quote

Advertisement

You can post new topics in this forum