Hello, I've got lot of tiff files. I need to create batch file (Windows only - if it is not possible linux bash script will be fine too) that will be creating folders based on filename. For example: File name is 406-1-0-0000-00.tiff so I need to create directory X:\406\1\0\0000\00\ and put that file there. 406-1-2-7019-03.tiff -> create directory X:\406\1\2\7019\03\ and copy this file to that directory ...and so on. Thanks in advance
@mad_max I use this https://forums.mydigitallife.net/threads/move-to-new-folder-context-menu.79414/ Not sure if this is exactly what you wanted
Thanx @freddie-o but I need something different. In my case there should be more folders - not just one based on a filename. For example my file is "406-1-2-7019-03.tiff" so I need something like that: Code: mkdir 406 cd 406 mkdir 1 cd 1 mkdir 2 cd 2 mkdir 7019 cd 7019 mkdir 03 cd 03 copy x:\406-1-2-7019-03.tiff z:\406\1\2\7019\03\ or just Code: mkdir z:\406\1\2\7019\03 copy x:\406-1-2-7019-03.tiff z:\406\1\2\7019\03\ and so on for about 300 files with different names (but same "naming method"). I think my batch file should: 1) take all of "-" from filename and change it to "\" so when we have got file 406-1-5-3011-00.tiff script create variable \406\1\5\3011\00 2) create folder based on 1) 3) copy file (with original name) to that folder made in 2) But I have no idea how to do it
Nobody can't because file, folder, directory names can't contain such a symbols: Code: \ / * : ? | " < > If You want use this z:\406\1\2\7019\03\, then it means z:\ - z-drive or partition 406 - folder 1 -folder what located in folder 406 2 - folder what located in floder 1 and the folder 1 located in folder 406 on z-drive or partition. etc
That is exacly what I'm trying to achive. My files contains only "-" symbols so I want to create 406 folder and 1 which is located inside that folder and 1 inside (and so on) and than copy file 406-1-2-7019-03.tiff to that folder.
Code: setlocal EnableDelayedExpansion for %%F in (*.tiff) do ( set sub=%%~nF set sub=X:\!sub:-=\! md !sub! copy /b %%F !sub! )