Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 -d geoip/');

shell_exec('rm -rf geoip/');
share|improve this question
Still trying to determine which dialect of BASH this user's using. Never heard of is_dir or shell_exec in BASH. PHP... sure. But that's not BASH. (They're PHP commands) – lornix Jun 24 '12 at 8:21
@lornix It is PHP. Arina, have you understood what these commands actually do? Do you know that they're shell commands wrapped in PHP? Have you tried looking for the Windows equivalents? – slhck Jun 24 '12 at 8:34
@slhck, I'm sorry for my mistake. I just know from you and lornix that those scripts are PHP. I'm sorry, I'm newbie. That's why I ask. this is because I catch the rm and mkdir which I also know that they are command in Linux. But thanks for reminding that is PHP. – arina Jun 24 '12 at 9:22

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.

share|improve this answer
with that application we can run the unix command in windows?? – arina Jun 24 '12 at 8:33
@arina Yes, you can. – slhck Jun 24 '12 at 8:39

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 -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.

share|improve this answer
deltree doesn't exist in XP, vista, or win7. "rmdir /S" is a good equivalent though. – RJFalconer Jun 24 '12 at 9:16
I'll try your code @lornix. I'll tell you what happened after I've tried them. Thank You. – arina Jun 24 '12 at 9:20
so what command in win7 to replace the "deltree"? – arina Jun 24 '12 at 9:21
rmdir /S /Q geoip is equivalent to deltree /Y geoip, I've edited my answer – lornix Jun 24 '12 at 9:24
  • Given a folder, unzips to that location
  • Given invalid path, makes dir and unzips
  • Given a file, renames that file to filename.old, makes dir and unzips


@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

echo %1 already exists and will be renamed. 
ren %1 %1.old

mkdir %1
attrib +r %1

unzip -oj -d geoip
echo Extraction test complete. Extracted files will now be deleted. 
attrib -r -s -h %1
rmdir /S /Q %1


script "my folder"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .