20 Useful Windows Commands For Managing 

Files BY usman world

May 24th, 2016

Most people do not normally use command prompt commands in windows as they find it
 easy to use it as a graphic user interface. Using commands is not limited to linux. You can
 use beautiful commands for doing zillions of things and that too at a pretty fast rate. The 
capability of commands on command prompt is immense. Here in this article , i have listed 
some useful Commands of command prompt in windows Os.

Create New File

Step 1: – First of all go to the respective folder, in which you want to create the file.


Step 2: – Now, Press shift and do a right click anywhere.
Step 3: – Now, Click on Open command prompt window here.
open-cmd-here
Note: – This is the quickest method to browse to any directory and open
 command prompt right from there.
Step 4: – Now, write the following command given below to create the file here.
fsutil file createnew filename.txt 3000
Note that 3000 is file size in KB. You are also telling windows to create the
 file with that much required size. You can create any file type. Just give the 
required extension , name and file size.
create-file-cmd

Find Files Older Than N Days Inside A Folder

To find files older than 1 day, use command given below.
forfiles /s /m *.* /d -1 /c "cmd /c echo @file

Find Files Modified In Last N Days

forfiles /P directory /S /D +(today'date - 10 days)

Find Files Larger Than A Specific Size

You can run forfiles command in this case.
For exampkle if you have to find files larger than 1 gb = 1073741824 bytes,
 the command would be as given below.
forfiles /S /M * /C "cmd /c if @fsize GEQ 1073741824 echo @path"
days-old-files
To find files larger than 1 MB use the given command.
forfiles /S /M * /C "cmd /c if @fsize GEQ 1048576 echo @path"
forfiles

Rename All File Extensions Inside A Folder At Once

Now, go to the folder where all the files are kept. Now, do a shift + right
 click to open command prompt there.
Now, just write the command given below to rename png to jpeg.
rename *.png*.jpeg
Note: – Just use any extensions in place of jpg and png above by replacing 
jpg and png with your required extensions.
The above command does not run recursively. It means , this command will
 not affect the files kept in subfolders.
To use it recursively use the given below command.
forfiles /S /M *.jpeg/C "cmd /c rename @file @fname.png"

In above command we are changing all files with .jpeg to .png .
recursively

Delete System Files In Windows

Who says you can’t delete system files. To delete system files:-
del /A:S systemfile.exe

Get File Creation Time And Date

Use the command given below to get the date and time when the file is created.
dir /T:C nameofthefile
file-creation-date-time

Find Out A String Inside A File

The command given below will fetch all lines and print them on screen having the word .
findstr string  file_name
For example if we have to find all lines containing windows in file.txt, then we 
will use command given below.
findstr windows file.txt
Note that, the above command is case sensitive. To do a case insensitive 
search add /I after the string.
findstr windows /I file.txt
You can also search for lines having any of the given strings.
findstr /C:"string1 string2 string3 string 4..."  filename

Take Ownership Of A File

takeown /F fileName

Get The List Of All Hidden Files Inside A Folder

To get the list of all hidden files and folders inside a directory use the given command.
dir /A:H /B
To get the full list of all hidden files / folders inside all sub-folders, use below 
given command.
dir /s /b /A:DH

Compress A File Using Command Line

compact /c filename

Hide A File Using Command Line

attrib +s + h file_name
The file hidden by this method cannot be seen even with windows normal 
show hidden files and folder option method.
To unhide the file again, use: –
attrib -s -h file_name

Set Read Only Attribute To A File

attrib +R file.doc
To remove read only attribute from the file again.
attrib -R file.doc

Delete A File In Windows Using CMD

For deleting the file Just go to the respective folder. do a shift + Right click 
and open command prompt window there.
Now use the command given below.
del filename.txt
To delete all the files in current folder
del *
To delete all the files with ‘.jpeg’ extension
del *.jpeg
To Delete all files having the ‘abc’ somewhere in file name
del *abc*

Rename A File Command

rename filename.txt newname.txt

Read File Command

Now, to read the contents of the file, just open command prompt at the location
 where the file is kept.
Now, just write the command given below.
more filename
read-file-cmd

Read Last 10 Or 20 Lines From A File

This Command will fetch last n lines from the file and display it on the command prompt 
window. You can read any number of lines from the file. Just replace 10 with any number.
tail -10 file.txt

Move File / Folder To Another Location

In this move command is followed by filename and the destination in which you want
 to move the file.
move file.doc  d:\new\folder\
Move all files of a common extension to a new folder.
move *.txt  d:\new\folder\
Move all files starting with letter C.
move C* d:\new\folder\
Similarly you can move folders to a new location. Just use the folder name.
move data d:\backup\new folder

Copy Files From One Destination To Another

To copy  all files inside a folder to another location
Xcopy /I Source_folder  Destination_folder
To copy all files and also sub-folders inside the folder as well.
Xcopy /S /I /E Source_folder Destination_folder
For example: –
Xcopy /S /I /E D:\backup\videos F:\new\media

Post a Comment

Thanks For Your Feed Back

 
Top