Home Forfiles Command Windows
Post
Cancel

Forfiles Command Windows

Forfiles digunakan untuk memilih satu atau lebih file lalu mengeksekusi perintah pada file tersebut. Perintah ini sangat berguna untuk batch job atau menjalankan perintah pada banyak file tanpa mengesekusi satu per satu.

Syntax

FORFILES [/P pathname] [/M searchmask] [/S]
         [/C command] [/D [+ | -] {MM/dd/yyyy | dd}]

Examples

List nama file pada direktori saat ini yang tidak diubah (last modified) selama 30 hari terakhir.

1
forfiles /d -30

Hapus file yang tidak diubah selama 30 hari terakhir

1
forfiles /d -30 /c "cmd /c del @file"

Cari setiap file dengan ekstensi .txt lalu buka dengan notepad

1
forfiles /m "*.txt" /c "cmd /c notepad @file"

Pindahkan semua file yang terakhir ubah sebelum 15 Maret 2018 dengan ekstensi .zip pada dir C:\Users\myuser\Downloads ke tujuan C:\Users\myuser\backups

1
forfiles /s /p "C:\Users\myuser\Downloads" /m "*.zip" /d -"03/15/2018" /c "cmd /c move @path C:\Users\myuser\backups"
This post is licensed under CC BY 4.0 by the author.