Forrest logo
back to context overview

for

List of commands for for:

  • for:ai:09f7c Execute a command in a loop for a range of values
    $ for i in {start..end}; do command; done
    try on your machine
    explain this command
  • for:ai:26703 How to rename files to add the creation date in the file name?
    $ for %f in (*.*) do ren "%f" "%~tf_%~nf%~xf"
    try on your machine
    explain this command
  • for:ai:40f06 cmd code for getting list of files in a directory and loop processing one file at a time
    $ for %i in (C:\path\to\directory\*.txt) do (echo %i)
    try on your machine
    explain this command
  • for:ai:605eb Simulate pressing the right arrow key 11 times using xdotool command
    $ for i in {1..11}; do xdotool key Right; done
    try on your machine
    explain this command
  • for:ai:bb05e how do i convert a folder of .wavs into .mp3s?
    $ for file in *.wav; do ffmpeg -i $file ${file%.wav}.mp3; done
    try on your machine
    explain this command
  • for:tldr:26ead for: Iterate over a given range of numbers.
    $ for /l %${variable} in (${from}, ${step}, ${to}) do (${echo Loop is executed})
    try on your machine
    explain this command
  • for:tldr:55752 for: Execute given commands for the specified set.
    $ for %${variable} in (${item_a item_b item_c}) do (${echo Loop is executed})
    try on your machine
    explain this command
  • for:tldr:56125 for: Execute the given commands for each of the specified items.
    $ for ${variable} in ${item1 item2 ---}; do ${echo "Loop is executed"}; done
    try on your machine
    explain this command
  • for:tldr:7520f for: Perform a given command in every directory.
    $ for /d %${variable} in (*) do (if exist %${variable} ${echo Loop is executed})
    try on your machine
    explain this command
  • for:tldr:c79fc for: Iterate over a given range of numbers.
    $ for ${variable} in ${{from}..${to}..${step}}; do ${echo "Loop is executed"}; done
    try on your machine
    explain this command
  • for:tldr:cf1af for: Iterate over a given list of directories.
    $ for /d %${variable} in (${path\to\directory1-ext path\to\directory2-ext ---}) do (${echo Loop is executed})
    try on your machine
    explain this command
  • for:tldr:e7e74 for: Perform a given command in every directory.
    $ for ${variable} in */; do (cd "$${variable}" || continue; ${echo "Loop is executed"}) done
    try on your machine
    explain this command
back to context overview