With the new MOVE, here is the new version of this script -
code:
;Test environment: Windows XP
;Kix Version: 4.21+
;Kent Dyer
;07-August-2003
;version .81
;Test: Create a simple text file called ScripTest and insert some text in it
;Findings: a file name and folder name of the same name cannot exist on the same volume
; also works with a zero-byte file too.
;Thanks: to bxn from http://kixtart.org for pointing out the error 183 when a file exists with
;same name as the folder
;using Kixtart commands
BREAK ON
CLS
;Trying To Create A Folder as Necessary
$foldernametocheck = "C:\ScriptTest"
$lenfolder = Len($foldernametocheck)
$foldername = substr($foldernametocheck,4,$lenfolder)
$drv=Left($foldernametocheck,3)
; - First check to see if this is a file
IF EXIST($foldernametocheck) AND NOT (GETFILEATTR($foldernametocheck) & 16)
? $foldernametocheck + " appears to exist as a file"
?'Press Y and <ENTER> to continue and rename the file and create the folder'
?'Press N and <ENTER> to exit'
?'>'
GETS $k
IF $k = 'Y'
IF @KIX<'4.21'
SHELL '%comspec% /c ren ' + $foldernametocheck + ' ' + $foldername + 1
ELSE
;MOVE $foldernametocheck $foldername + '1' ; This deletes the file,
;you need to define the drive letter
MOVE $foldernametocheck $drv+$foldername+'1'
ENDIF
?'Creating '+ $foldernametocheck + ' now'
MD $foldernametocheck
IF @error <> 0
?@error
SLEEP 2
ENDIF
ELSE
RETURN
ENDIF
ENDIF
IF EXIST($foldernametocheck) AND (GETFILEATTR($foldernametocheck) & 16)
?$foldernametocheck + ' Appears to exist as a folder.'
SLEEP 2
RETURN
ELSE
?'Creating ' + $foldernametocheck + ' now'
MD $foldernametocheck
IF @error <> 0
?@error
SLEEP 2
ENDIF
ENDIF
? 'File/folder checks complete'
? 'Press any Key to exit'
GET $l
Kent
[ 07. August 2003, 14:43: Message edited by: kdyer ]