Z
Z
ZhanZhak2020-06-30 14:36:30
Automation
ZhanZhak, 2020-06-30 14:36:30

How to automatically create folders by file name and sort files there?

There is a folder with many files, with different names,
how to make folders automatically created in accordance with the first 10 characters of the file and all these files are thrown into the appropriate folder5efb237ea6045401288654.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hint000, 2020-06-30
@ZhanZhak

@echo off
rem https://stackoverflow.com/questions/8648178/getting-substring-of-a-token-in-for-loop
setlocal EnableDelayedExpansion
for %%f in ("*.xls") do (
    set T1=%%f
    set T=!T1:~0,10!
    if not exist !T! md !T!
    move %%f !T!
)

S
Stalker_RED, 2020-06-30
@Stalker_RED

iterate over files:

for %%f in (directory\path\*.txt) do (
  echo "fullname: %%f"
)

get chunk name like this
create folder mkdir
move filemove

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question