I am looking for a command in the windows terminal that allows me to unrar all the files from a folder. Precisely I want to replicate this bash command on windows
find . -name "*.rar" -exec unrar x -o+ {} \;
thank u
I would prefer RS Finance's answer: a power shell provides an easy and clean solution. However, if that's not an option, you may achieve the same with command prompt like this (first cd to the correct directory),
for %i in (*.rar) do "C:\Program Files\7-Zip\7z.exe" e "%i"
I use 7z as my zip program. You just have to replace the path to whatever you use. If you have the path stored in you environment path, "7z.exe" without the absolute path may be enough.
Note that,
e is an argument specifically for 7zip, meaning extract.
if you intend to do this in a batch script (file), you'll need double "%"-signs. See this one: Iterate all files in a directory using a 'for' loop
Well Powershell would be a great option, something like this should do the trick:
Get-ChildItem -File *.rar | Foreach {unrar x -o+ $_.fullname}
It's better to use UnRAR.exe supplied with WinRAR Trial. This console utility is freeware, and definitely supports all RAR format versions
e.g.
for %i in (*.rar) do "C:\Program Files (x86)\WinRAR\UnRAR.exe" x "%i"
to extract all archives contents with relative paths or
for %i in (*.rar) do "C:\Program Files (x86)\WinRAR\UnRAR.exe" e "%i"
to extract everything to the same folder
Related
i recently started working on windows operation system(2012 R2) and i am trying to find all files with header format (*.h) in my directory and it subdirectories .
this how i got it when i ran in linux shell :
find /auto/sw_work/fwshared/ibrahims/git/svx/pci_verification -name "*.h"
i got the following results :
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/BlockStateMainProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/BlueFieldBdfProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/CfgLastIndexProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/CfgLastIndexPropertyProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/ComponentIsUpstreamProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/ConfigTraceProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/DmesgProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/DriverProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/HeaderLogProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/HotPlugProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/I1FrequencyProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/LinkEqProperty.h
how can i get the following results when running in windows command line?
thank in advance .
That's an easy one.
The command to list files is dir. See dir /? for various switches.
dir /s /b "\auto\sw_work\fwshared\ibrahims\git\svx\pci_verification\*.h"
The /s switch looks recursive (including subfolders), the /b switch will show the files in bare format (no header, no summary, timestamps or size)
Note: the directory separator in Windows is \, not / as in Unix/Linux.
I'm a newbie. I am trying to figure out how to use the command line. Please could you tell me what command I should enter so that I can get a list of all the exe files on my computer. thanks.
You can use the dir functionality to search the directory and all of its children directories while filtering on a particular file type.
dir /s /b *.exe | findstr /v .exe.
Source
If you want to find all the executable files that are on the path and/or in the current directory, i.e., all the files you can run from the command line without specifying a path, this should work:
where *.exe
To get names of all .exe files , that are currently running then type tasklist in cmd.
http://ss64.com/nt/tasklist.html
Here's another method I use a lot for tasks like this.
Open powershell and navigate to your root directory by entering the command
cd c:/
cd stands for change directory, and is an alias for the command "Set-Location". We are setting the location to C:/
Next run the following command:
Get-ChildItem -Filter "*.exe" -Recurse
Get-ChildItem is a function that gets the files and folders in a file system drive, and runs on whatever directory you're current at by default.
-Filter "*.exe" is an argument that specifies to only find filenames which end in ".exe". (The * is a type of regular expression notation).
-Recurse is an argument that specifies to search all child directories. This will make your function run on "C:/", but also all child directories of C:/, and all child directories of those directories and so on. This will allow you to search the entire drive.
How can I extract about 900 7z files which are all located in the same folder (all have only one file inside) without doing it one by one?
I am using Ubuntu 10.10. All files are located in /home/username/folder1/folder2.
7za -y x "*.7z"
The above code worked for me
for arc in *.7z
do
7zwhatever "$arc"
done
Using parallel is rather convenient way with total progress meter for free ;)
ls *.7z | parallel -j+0 --eta '7z x {} >/dev/null'
7z x "*.7z"
this worked for me in ubuntu
for f in *.7z
do
7zr e "$f" &
done
This will extract all .7z files if they're 7z format to the current directory, without waiting for completion.
Your computer could be owned. You have been warned!
If you wish to extract multiple 7zip archives to folders with the same names in Linux, you can use:
for archive in *.7z; do 7z x -o"`basename \"$archive\" .7z`" "$archive"; done
For example, if you have two 7zip archives a.7z and b.7z, it will create two folders a and b, and uncompress a.7z into folder a and b.7z into folder b.
The above command comes from this answer on superuser by user Vojtech.
You do not need to overcomplicate things. To extract a 7-Zip archive split to multiply parts use the following command:
7z x archive.7zip.0
7-Zip will notice you that you have a multi-volume archive and it unpacks everything.
Probably the simplest approach is below
ls | xargs -n1 7z x
in adition to using a for loop
you can also use find in combination with the exec argument or xargs
The simplest way is unzip '*.zip'.
Make sure you have the ' marks.
I have to list folders and sub-folders from a given directory in DOS and Unix. I know i cand make this with DIR command, as follows: dir directory /ad /s, but the assignment tells me that I have to make it with find. It works with dir, but i have no idea how to make it with find. And I have to make it in UNIX too, so if you have some hints or something, please let me know.
Thanks.
Windows native find command is for finding strings in files or stdin, not for listing file names. download findutils for windows, then you can use find the same as what you used in Unix
WindowS:
C:\test> gnu_find.exe c:\path
Unix:
find /path
Is there some way to specify a directory (let's say "C:\images") and move every .jpg file from there to another directory (say "D:\media") but preserve the directory structure (so if the file were "C:\images\paintball\july\07\headshot.jpg" after moving it would be "D:\media\paintball\july\07\headshot.jpg")?
I'm using cygwin (but would be happy to use DOS if that works too).
Yup.
Do a tar archive of *.jpg files while preserving directory structure (there's a switch) then extract it to the target directory. Should be a one-liner.
( cd /cygdrive/c/images
tar --create --file - . ) | ( cd /cygdrive/d/media
tar --extract --file - )
There's also a --directory option in some versions of tar with which you can avoid the complexity of piping between subshells, but I never use it myself, so I may be missing something:
tar --create --file - -C /cygdrive/c/images . | tar --extract --file - -C /cygdrive/d/media
If you need more power/flexibility, take the time to investigate rsync.
Since you're on windows, you could also take a look at xxcopy. It's great for this kind of stuff and much else.
You can also use xcopy command, like in this example (old is a directory):
xcopy cvs_src\*.jpg old /e/i/h/y/d/exclude:files_to_exclude
Thanks for the XCOPY solution, it solved my similar problem, so I thought I'd share the details for anyone else needing it.
I wanted a list (not a copy) of all the files in a directory (and sub-directories) that were not of a particular type, such as *.jpg. But the DIR command doesn't have an exclude function. So I:
Created a file named exclist.txt that contained a single line ".jpg"
Ran the command "xcopy c:\files c:\test /exclude:exclist.txt /l /d /e /h /i /y > found.txt"
Opened found.txt in Notepad to see the list of non-jpg files
Note the XCOPY /l parameter, which lists the files to be copied without copying them. Since XCOPY is executed in "list mode", the destination folder c:\test is not created and no files are copied. "> found.txt" saves the output from the XCOPY command to the file found.txt, rather than displaying the results on screen.