What are the equivalent commands in Windows if I have these commands in Linux?
if (!is_dir('geoip')) mkdir('geoip', 0744);
shell_exec('unzip -oj GeoLiteCity.zip -d geoip/');
shell_exec('rm -rf geoip/');
What are the equivalent commands in Windows if I have these commands in Linux?
if (!is_dir('geoip')) mkdir('geoip', 0744);
shell_exec('unzip -oj GeoLiteCity.zip -d geoip/');
shell_exec('rm -rf geoip/');
You should download and install GnuWin32 to get all the basic UNIX commands on Windows, for example, wget
, sed
, cat
, grep
, rm
, mkdir
, unzip
– all you need.
http://sourceforge.net/projects/getgnuwin32/files/latest/download?source=files
if you can afford to just ignore errors, then the following would work for your PHP commands:
(Hopefully you've got a statement prior to this putting your process in the proper subdirectory BEFORE you do this... like this)
cd c:\mystuff\temp\
mkdir geoip
unzip -oj GeoLiteCity.zip -d geoip/
rmdir /S /Q geoip/
If geoip already exists, the mkdir will return an error, but it's not fatal. Of course, if you unzip something on top of something pre-existing, you've got issues. But your original script doesn't cover that either.
rmdir /S /Q geoip/ will remove the subdir geoip and anything below it. same as rm -rf
BE CAREFUL with rmdir /S /Q, you can do stupid things with it quite easily.
script.bat
@echo off
IF NOT EXIST %1 GOTO Make_Folder
REM File exists, test to see if it's a folder
REM Get attributes of first param.
set ATTR=%~a1
REM if first character is "d", it's a folder
set DIRATTR=%ATTR:~0,1%
IF /I "%DIRATTR%"=="d" GOTO Extract
:Is_File
echo %1 already exists and will be renamed.
pause
ren %1 %1.old
:Make_Folder
mkdir %1
attrib +r %1
:Extract
unzip -oj GeoLiteCity.zip -d geoip
echo Extraction test complete. Extracted files will now be deleted.
pause
attrib -r -s -h %1
rmdir /S /Q %1
Usage
script "my folder"