Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Batch file

Name: Anonymous 2008-02-06 20:28

I need a batch file. This isn't some school assignment, and I know the elitists at /prog/ don't consider it a real programming language, but I'll try you guys anyway.
I need this batch file to swap two files in place, both having the same name. Obviously, they're not in the same directory, but at the end of execution, they should be swapped and ready to be swapped back.
Let's say, C:\File.ini  needs to be swapped for C:\Copy\File.ini.
Any suggestions?

Name: Anonymous 2008-02-06 20:35

#!/bin/sh
mkdir C:\Copy\temp
mv C:\Copy\File.ini C:\Copy\temp
mv C:\File.ini C:\Copy\
mv C:\Copy\temp\File.ini C:\File.ini
rmdir C:\Copy\temp

there, now find some way to run bash(or sh) on windows.

Name: Anonymous 2008-02-06 20:36

or put whatever that would be into batch.

Name: Anonymous 2008-02-06 20:36

@echo off
for %%a in (%1) do set tmppath=%%~dpa
for /f "delims=:. tokens=1-4" %%a in ("%time: =0%") do set tmpname=%tmppath%%%a%%b%%c%%d
move "%1" "%tmpname%"
move "%2" "%1"
move "%tmpname%" "%2"

Name: Anonymous 2008-02-06 20:48

Thanks.
I got it working myself, though, i forgot only ONE file was needed. So i stuck both in the same directory and made a batch to swap them via renaming.

@ECHO OFF
rename settings.ini A.txt
rename B.txt settings.ini
rename A.txt B.txt

Name: Anonymous 2009-08-17 0:46

Lain.

Name: Anonymous 2010-11-27 18:20

<

Don't change these.
Name: Email:
Entire Thread Thread List