Create a dummy file with the name of the parent folder name

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MrTBE
Posts: 2
Joined: 30 Mar 2013 14:05

Create a dummy file with the name of the parent folder name

#1 Post by MrTBE » 30 Mar 2013 16:21

Hi All,

I wonder if someone has a tip for how to create a dummy .txt file inside a folder with the file name of the parent folder.

If I have folder with sub-folders I would like to create one file in each folder.

With the command below I get the file created, but it in the same level as the parent folder, not inside the parent folder.

for /d /r %%G in (*) do (type NUL > %%G.txt)

I wonder if someone have any good ideas?

Thanks!

Endoro
Posts: 244
Joined: 27 Mar 2013 01:29
Location: Bozen

Re: Create a dummy file with the name of the parent folder n

#2 Post by Endoro » 30 Mar 2013 17:34

inside is inside

Code: Select all

for /d /r %%G in (*) do (type NUL > "%%~G\%%~nxG.txt")



edit: added "nx".
Last edited by Endoro on 30 Mar 2013 20:41, edited 1 time in total.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Create a dummy file with the name of the parent folder n

#3 Post by Squashman » 30 Mar 2013 18:15

missing the modifiers.

Code: Select all

for /d /r %%G in (*) do (type NUL > "%%~G\%%~nxG.txt")

MrTBE
Posts: 2
Joined: 30 Mar 2013 14:05

Re: Create a dummy file with the name of the parent folder n

#4 Post by MrTBE » 30 Mar 2013 20:10

Works perfect!
1000 thanks!

Post Reply