moving files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: moving files

#16 Post by aGerman » 05 Apr 2018 09:58

joejames_786 wrote:
05 Apr 2018 09:53
I was just wondering what happened to steffen!!
What happened to me every day - I had to work :wink:

batnoob
Posts: 56
Joined: 19 Apr 2017 12:23

Re: moving files

#17 Post by batnoob » 05 Apr 2018 10:10

five lines :shock: :shock: :shock:
it seems i still have a lot to learn.

joejames_786
Posts: 17
Joined: 12 Feb 2017 05:11

Re: moving files

#18 Post by joejames_786 » 05 Apr 2018 10:15

HI

yes steffen is king of the trade so far as me a non programmer he has given me lots of solutions
without hesitating if you r a programmer there's lot more to learn from him

iam one of his fan :D

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: moving files

#19 Post by aGerman » 05 Apr 2018 10:24

Too much guys, I become stuck-up :lol:
Speaking of learning: If there's something you don't understand in my code then please ask.

Steffen

batnoob
Posts: 56
Joined: 19 Apr 2017 12:23

Re: moving files

#20 Post by batnoob » 05 Apr 2018 10:32

aGerman wrote:
05 Apr 2018 09:48

Code: Select all

@echo off &setlocal DisableDelayedExpansion
for %%i in (*.*) do if "%%~i" neq "%~nx0" for /f "tokens=* delims=." %%j in ("%%~xi") do (
  if not exist "%%j\" md "%%j"
  move "%%~i" "%%j\"
)
Steffen

Code: Select all

 
for /f "tokens=* delims=." %%j in ("%%~xi")
What is %%~xi? (you said i could ask... its easier than sifting through google)

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: moving files

#21 Post by aGerman » 05 Apr 2018 10:42

You don't need google to find out how a certain command works. Just execute COMMAND /? (FOR /? in that case).
To answer your question - the ~x is a modifier to expand the FOR variable to the file extension only. "tokens=* delims=." removes the leading dot. Finally the extension without the dot is assigned to %%j.

Steffen

batnoob
Posts: 56
Joined: 19 Apr 2017 12:23

Re: moving files

#22 Post by batnoob » 05 Apr 2018 10:45

ohh... now it all makes sense, htnks for explanation

Post Reply