I know the title doesn't make sense so I'll try to elaborate:
I have a program called My App.exe and when I run it, it creates a file in a folder in AppData. The name of the folder it creates varies for every machine. Example:
When My App.exe is run on one computer, it creates this file:
%LocalAppData%\Kazankoph\My_App.exe_Url_3p43oix65iqigwb4lndfi4m34sf1xjg3\1.2.0.0\Settings.dat
When its run on another machine it creates this file:
%LocalAppData%\Kazankoph\My_App.exe_Url_6f47ntd26lwubpr3hunvt2m67sf1xtq2\1.2.0.0\Settings.dat
The only things that stay the same are the parent folder "Kazankoph", the child folder "1.2.0.0" and the file name settings.dat
It seems that the text that comes after "My_App.exe_Url_" is always 32 characters long, and is randomly generated
XCOPY settings.dat "%LocalAppData%\Kazankoph\My_App.exe_Url_6f47ntd26lwubpr3hunvt2m67sf1xtq2\1.2.0.0" /y
But the problem with that code is that it only works for that one computer.
I want a code that will work on any computer regardless of the 32 character code.
something like this:
XCOPY settings.dat "%LocalAppData%\Kazankoph\My_App.exe_Url_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\1.2.0.0" /y
Of course this one doesn't work but you get the idea.
Anyone have any suggestions?
Run this and it should give you the folder, and copy the file from the current directory into the folder.
@echo off
for /f "delims=" %%a in (' dir /b /s /a-d "%LocalAppData%\Kazankoph\Settings.dat" ') do set "folder=%%~dpa"
echo copying settings.dat to "%folder%"
copy /y "settings.dat" "%folder%\"
pause