topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday October 31, 2024, 6:29 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Need a recursive utility  (Read 2996 times)

fdwojo

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 20
  • My CASTLE is my home (and Stana should be, too).
    • View Profile
    • Donate to Member
Need a recursive utility
« on: May 27, 2021, 05:35 PM »
Hey there folks. I'm in need of a utility that can either:

1) allow me to execute a standard DOS/CMD command in every sub-directory of a particular folder
  or
2) create a 0-byte file in every sub-directory of a particular folder, all with the same name of my choice.

Way back in the day of Windows 95 and MS-DOS, I had a tool that would do option #1, but it seems those older 16-bit tools don't work in Windows 10. I've tried the FOR /R tool, but it doesn't seem to be able to create files, only manipulate existing files which is no help.

Does anyone know where I could find a tool like that? *** or *** could someone here write a utility that will do that?

Thanks for reading! Please let me know if you have any thoughts of an existing tool, or if creating one is possible.
==================================
No matter where you go, there you are… - B.B. 1984
-------------------------------------------------------
My System: Win 10 Pro 64-bit. Currently updated to version 21H1. RAM: 64GB, CPU: Intel Core i7 6700 CPU @ 4.0 GHz, and if it matters, ~½ TB space left on C:
« Last Edit: May 27, 2021, 05:40 PM by fdwojo »

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,644
    • View Profile
    • Donate to Member
Re: Need a recursive utility
« Reply #1 on: May 27, 2021, 06:48 PM »
Simple PowerShell script to create zero byte file in all sub-directories:

Code: PowerShell [Select]
  1. <#
  2. p0b.ps1
  3.  
  4. In a Powershell console:
  5.  
  6. path/to/p0b.ps1 -dir <dir> -file <file>
  7.  
  8. Example:
  9.  
  10. ./p0b.ps1 -dir r:/abc -file hello.txt
  11.  
  12. #>
  13.  
  14. param (
  15.   [Parameter(Mandatory = $true)][string]$dir,
  16.   [Parameter(Mandatory = $true)][string]$file
  17. )
  18.  
  19. # Get a list of all sub-dirs
  20. Get-ChildItem -Path $dir -Recurse -Directory | `
  21. # For each one create a file
  22.   ForEach-Object { New-Item "$($_)/$($file)" -ItemType File -Force}

NOTE: The -Force parameter will cause existing files to be overwritten, remove it if necessary.

PS. PowerShell doesn't care what you use for a path separator, / or \
« Last Edit: May 27, 2021, 06:56 PM by 4wd »

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
Re: Need a recursive utility
« Reply #2 on: June 13, 2021, 06:05 PM »
could someone here write a utility that will do that?

Hi there! :) Adding RecuRUN to the thread:

https://www.donation...ex.php?topic=51481.0

RecuRUN_v0-1-0.pngNeed a recursive utility

Enjoy! :Thmbsup:
Vic
My name's Victor but do feel free to call me Vic! (now known as "paradisusvic")

❤️ Support on Patreon @ www.patreon.com/paradisusis
New Email/Paypal: paradisusvicgmail.com