BAT file to write to a folder that has random name

I am trying to create a BAT file that will write a file to a folder that is named something different within each users profile.

I would like to copy a file to the following folder...

C:\Users\%username%\AppData\Local\Google\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\T2SHBFKV\program.kwtears.com\#hwtears\kwt\

The folder that is different for each user is: T2SHBFKV

 I found the following but could not adapt it to suite my needs and I was hoping someone could help....


for /D %%A in ("%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\*\program.kwtears.com\#hwtears\kwt\") do xcopy "\\*Internal Server*\appData.sol" "%%~A" 


When this runs I do not get an error but the file is not copied.  That said when I take the "\program.kwtears.com\#hwtears\kwt\" out I am able to write to the random folder but it just simply can't write to any of the sub folders within that random folder.

Thanks for the help!

August 23rd, 2015 7:58pm

Try this:

@echo off
set Folder1=%UserProfile%\AppData\Local\Google\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects
for /D %%a in ("%Folder%\*.*") do set Folder2=%%a\program.kwtears.com\#hwtears\kwt

echo %Folder2%

Free Windows Admin Tool Kit Click here and download it now
August 24th, 2015 5:39am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics