Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Windows › How to create .bat to copy a file within the same directory as .bat to directory?
New Posts  All Forums:Forum Nav:

How to create .bat to copy a file within the same directory as .bat to directory?

post #1 of 8
Thread Starter 
I'm looking to create an auto-install for a config I made for a game.

The filename is PrimalCarnageSystemSettings.ini

the directory i want it to go is C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\

so basically I want to share this with people and so all they need to do is copy their config file of choice to the .bat directory and double-click install done. By using a command that will assume the file I'm copying is in the same directory as the .bat so no source would need to be typed in.

That way it can universally just be like


echo on
@echo "ULTRA HIGH QUALITY GRAPHICS CONFIG FOR PRIMAL CARNAGE *STEAM*"

copy /Y PrimalCarnageSystemSettings.ini C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\


What's the best way to setup the .bat for the echo to only show the text i want it to show and maybe have a 2 step process like saying Installing config file... Done Installing config file...

so basically i want the .bat to assume the file is in the same directory as the .bat no matter where the file is located. I also want to assure that the file retains it's "Read-Only" attribute after copy and overwriting the original.

THANKS
Edited by chris89 - 5/30/13 at 1:10am
post #2 of 8
So, you want to copy a file from its directory it is, to another one, and turn it into a .bat in the process? Please confirm?

You also want this to be no user interaction, is this correct?
     
CPUMotherboardGraphicsRAM
Intel Core i7 3820 @ 4.5Ghz ASUS Rampage IV Formula X79 EVGA GTX 980 Ti Hybrid @ 1450/1900 Corsair Dominator 16gb @ 2.2GHz C9 
Hard DriveHard DriveHard DriveCooling
WD Caviar Blue 1tb 7200RPM WD Caviar Blue 1tb 7200RPM WD Caviar Blue 500gb 7200RPM 120.5 Custom Loop 
OSMonitorKeyboardPower
Windows 10 Pro x64 LG D2343P-BN 3D Monitor @ 70Hz Corsair K70 (MX Brown) Corsair AX Series 850w 
CaseMouseAudio
NZXT Switch 810 Black (Heavily Modded) Logitech G502 Proteus Spectrum Sennheiser HD 598 Cs 
CPUMotherboardGraphicsRAM
AMD FX-6300 @ 4.5Ghz Gigabyte 970A UD3 AMD HD8490 (OEM) @ 1.1Ghz Core/Mem Patriot Viper Xtreme 8gb @1600MHz 8-8-8-24 
Optical DriveCoolingCoolingOS
LiteOn Bluray Player Corsair Hydro Series H100i Zalman 120mm Led Fans x4 Windows 10 Pro x64 
MonitorKeyboardPowerCase
Hitachi 24" 70Hz Monitor Logitech EX110 OCZ ZT 550w Full Modular Zalman Z9 Plus 
MouseAudioOther
DELL Wireless Mouse Logitech 5.1 Sound System TP-Link TL-WN781ND Wireless Card 
  hide details  
Reply
     
CPUMotherboardGraphicsRAM
Intel Core i7 3820 @ 4.5Ghz ASUS Rampage IV Formula X79 EVGA GTX 980 Ti Hybrid @ 1450/1900 Corsair Dominator 16gb @ 2.2GHz C9 
Hard DriveHard DriveHard DriveCooling
WD Caviar Blue 1tb 7200RPM WD Caviar Blue 1tb 7200RPM WD Caviar Blue 500gb 7200RPM 120.5 Custom Loop 
OSMonitorKeyboardPower
Windows 10 Pro x64 LG D2343P-BN 3D Monitor @ 70Hz Corsair K70 (MX Brown) Corsair AX Series 850w 
CaseMouseAudio
NZXT Switch 810 Black (Heavily Modded) Logitech G502 Proteus Spectrum Sennheiser HD 598 Cs 
CPUMotherboardGraphicsRAM
AMD FX-6300 @ 4.5Ghz Gigabyte 970A UD3 AMD HD8490 (OEM) @ 1.1Ghz Core/Mem Patriot Viper Xtreme 8gb @1600MHz 8-8-8-24 
Optical DriveCoolingCoolingOS
LiteOn Bluray Player Corsair Hydro Series H100i Zalman 120mm Led Fans x4 Windows 10 Pro x64 
MonitorKeyboardPowerCase
Hitachi 24" 70Hz Monitor Logitech EX110 OCZ ZT 550w Full Modular Zalman Z9 Plus 
MouseAudioOther
DELL Wireless Mouse Logitech 5.1 Sound System TP-Link TL-WN781ND Wireless Card 
  hide details  
Reply
post #3 of 8
Thread Starter 
Yes thats correct. I want it to simply copy the .ini to the directory retaining read-only. I would also like for it to possibly first backup the original .ini to the directory of where the .bat is in, in a "backup" folder first. then copy and replace the file.

say they want to copy a new config file and it will overwrite the backup in the backup folder. Basically I would like for it to see there's already a file of the same filename in the backup and ignore the backup function leaving the original backup.

Yes, No User Interaction.
Edited by chris89 - 5/30/13 at 1:21am
post #4 of 8
echo on
@echo "ULTRA HIGH QUALITY GRAPHICS CONFIG FOR PRIMAL CARNAGE *STEAM*"

@echo "Press 'Space' To Install"
pause


xcopy \%~dp0/\rimalCarnageSystemSettings.ini C:\end directory path

that should copy the file from the current directory, to another, all you need to do is chance the bo;ld bit to th end directory
     
CPUMotherboardGraphicsRAM
Intel Core i7 3820 @ 4.5Ghz ASUS Rampage IV Formula X79 EVGA GTX 980 Ti Hybrid @ 1450/1900 Corsair Dominator 16gb @ 2.2GHz C9 
Hard DriveHard DriveHard DriveCooling
WD Caviar Blue 1tb 7200RPM WD Caviar Blue 1tb 7200RPM WD Caviar Blue 500gb 7200RPM 120.5 Custom Loop 
OSMonitorKeyboardPower
Windows 10 Pro x64 LG D2343P-BN 3D Monitor @ 70Hz Corsair K70 (MX Brown) Corsair AX Series 850w 
CaseMouseAudio
NZXT Switch 810 Black (Heavily Modded) Logitech G502 Proteus Spectrum Sennheiser HD 598 Cs 
CPUMotherboardGraphicsRAM
AMD FX-6300 @ 4.5Ghz Gigabyte 970A UD3 AMD HD8490 (OEM) @ 1.1Ghz Core/Mem Patriot Viper Xtreme 8gb @1600MHz 8-8-8-24 
Optical DriveCoolingCoolingOS
LiteOn Bluray Player Corsair Hydro Series H100i Zalman 120mm Led Fans x4 Windows 10 Pro x64 
MonitorKeyboardPowerCase
Hitachi 24" 70Hz Monitor Logitech EX110 OCZ ZT 550w Full Modular Zalman Z9 Plus 
MouseAudioOther
DELL Wireless Mouse Logitech 5.1 Sound System TP-Link TL-WN781ND Wireless Card 
  hide details  
Reply
     
CPUMotherboardGraphicsRAM
Intel Core i7 3820 @ 4.5Ghz ASUS Rampage IV Formula X79 EVGA GTX 980 Ti Hybrid @ 1450/1900 Corsair Dominator 16gb @ 2.2GHz C9 
Hard DriveHard DriveHard DriveCooling
WD Caviar Blue 1tb 7200RPM WD Caviar Blue 1tb 7200RPM WD Caviar Blue 500gb 7200RPM 120.5 Custom Loop 
OSMonitorKeyboardPower
Windows 10 Pro x64 LG D2343P-BN 3D Monitor @ 70Hz Corsair K70 (MX Brown) Corsair AX Series 850w 
CaseMouseAudio
NZXT Switch 810 Black (Heavily Modded) Logitech G502 Proteus Spectrum Sennheiser HD 598 Cs 
CPUMotherboardGraphicsRAM
AMD FX-6300 @ 4.5Ghz Gigabyte 970A UD3 AMD HD8490 (OEM) @ 1.1Ghz Core/Mem Patriot Viper Xtreme 8gb @1600MHz 8-8-8-24 
Optical DriveCoolingCoolingOS
LiteOn Bluray Player Corsair Hydro Series H100i Zalman 120mm Led Fans x4 Windows 10 Pro x64 
MonitorKeyboardPowerCase
Hitachi 24" 70Hz Monitor Logitech EX110 OCZ ZT 550w Full Modular Zalman Z9 Plus 
MouseAudioOther
DELL Wireless Mouse Logitech 5.1 Sound System TP-Link TL-WN781ND Wireless Card 
  hide details  
Reply
post #5 of 8
Thread Starter 
Quote:
Originally Posted by PedroC1999 View Post

echo on
@echo "ULTRA HIGH QUALITY GRAPHICS CONFIG FOR PRIMAL CARNAGE *STEAM*"

@echo "Press 'Space' To Install"
pause


xcopy \%~dp0/\rimalCarnageSystemSettings.ini C:\end directory path

that should copy the file from the current directory, to another, all you need to do is chance the bo;ld bit to th end directory

Okay thanks man! So basically this is what I would like for it to do...

@echo "ULTRA HIGH QUALITY GRAPHICS CONFIG FOR PRIMAL CARNAGE *STEAM*"

@echo "Press 'Space' To Install"
pause

mkdir \%~dp0\backup
xcopy C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\PrimalCarnageSystemSettings.ini \%~dp0\backup\
xcopy C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\PrimalCarnageEngine.ini \%~dp0\backup\
xcopy \%~dp0\PrimalCarnageSystemSettings.ini C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\
xcopy \%~dp0\PrimalCarnageEngine.ini C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\

@echo "BACKUP & INSTALLATION COMPLETE!*
pause

Will that retain the "read-only" attribute on the files placed in the directory of the .bat?

Thanks

It doesn't seem to work.... Says "invalid number of parameters"

I'd like for it to not show the commands if possible... Only the echo text and installation info discluding showing the commands...

1) mkdir backup within the directory of the .bat

2)copy C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\PrimalCarnageSystemSettings.ini to backup folder

3)copy C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\PrimalCarnageEngine.ini to backup folder

4) copy and replace PrimalCarnageSystemSettings.ini while retaining read-only attribute to C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\

5)copy and replace PrimalCarnageEngine.ini while retaining read-only attribute to C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\

6)complete

Edited by chris89 - 5/30/13 at 1:51am
post #6 of 8
very simply :

cd %cd%
xcopy /Y C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\PrimalCarnageSystemSettings.ini PrimalCarnageSystemSettings.ini.old
xcopy /Y PrimalCarnageSystemSettings.ini C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config\PrimalCarnageSystemSettings.ini

the first xcopy will create the backup ini in the current dir, the second will overwrite the game's ini with yours. You can add echo if you want
deus ex machina
(14 items)
 
  
Reply
deus ex machina
(14 items)
 
  
Reply
post #7 of 8
xcopy say it normaly copies atributes. In the case it doesn't use the /K
deus ex machina
(14 items)
 
  
Reply
deus ex machina
(14 items)
 
  
Reply
post #8 of 8
Thread Starter 
"ULTRA HIGH QUALITY GRAPHICS CONFIG FOR PRIMAL CARNAGE *STEAM*"
"Press 'Space' To Install"

D:\GAME BACKUPS\Primal Carnage\Config\modded\COPY HERE TO INSTALL>pause
Press any key to continue . . .

D:\GAME BACKUPS\Primal Carnage\Config\modded\COPY HERE TO INSTALL>cd D:\GAME BAC
KUPS\Primal Carnage\Config\modded\COPY HERE TO INSTALL

D:\GAME BACKUPS\Primal Carnage\Config\modded\COPY HERE TO INSTALL>xcopy /Y C:\Pr
ogram Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config
\PrimalCarnageSystemSettings.ini PrimalCarnageSystemSettings.ini.old
Invalid number of parameters

D:\GAME BACKUPS\Primal Carnage\Config\modded\COPY HERE TO INSTALL>xcopy /Y Prima
lCarnageSystemSettings.ini C:\Program Files (x86)\Steam\steamapps\common\primal_
carnage\PrimalCarnageGame\Config\PrimalCarnageSystemSettings.ini
Invalid number of parameters

D:\GAME BACKUPS\Primal Carnage\Config\modded\COPY HERE TO INSTALL>xcopy /Y C:\Pr
ogram Files (x86)\Steam\steamapps\common\primal_carnage\PrimalCarnageGame\Config
\PrimalCarnageEngine.ini PrimalCarnageSystemSettings.ini.old
Invalid number of parameters

D:\GAME BACKUPS\Primal Carnage\Config\modded\COPY HERE TO INSTALL>xcopy /Y Prima
lCarnageEngine.ini C:\Program Files (x86)\Steam\steamapps\common\primal_carnage\
PrimalCarnageGame\Config\PrimalCarnageEngine.ini
Invalid number of parameters
"BACKUP & INSTALLATION COMPLETE!*

D:\GAME BACKUPS\Primal Carnage\Config\modded\COPY HERE TO INSTALL>pause
Press any key to continue . . .
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Windows
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Windows › How to create .bat to copy a file within the same directory as .bat to directory?