1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved Cycle the names of several text files

Discussion in 'DOS/Other' started by DocBenOrdway, Jan 25, 2016.

Thread Status:
Not open for further replies.
Advertisement
  1. DocBenOrdway

    DocBenOrdway Thread Starter

    Joined:
    Jan 25, 2016
    Messages:
    8
    I want to cycle the names of several text files. I haven't done anything like this in over 25 years.

    Example:
    Start with - base.tax
    2.txt
    3.txt

    Theory -
    @Echo off
    Rename 3.txt tmp.txt
    Rename 2.txt 3.txt
    Rename base.txt 2.txt
    Rename tmp.txt base.txt
    Delete tmp.txt

    This should be ready to go again and make the original 2.txt the new base.txt.

    The plan is to schedule the batch file to run (at a time & repeat yet to be determined) with Windows Task Scheduler.

    I am currently on Windows 10 but will probably get smart and go back to Windows 8.1 later this week.
     
  2. foxidrive

    foxidrive Banned

    Joined:
    Oct 20, 2012
    Messages:
    793
    It helps to describe the task fully to avoid misunderstandings, and you may get a far better solution.
     
  3. DocBenOrdway

    DocBenOrdway Thread Starter

    Joined:
    Jan 25, 2016
    Messages:
    8
    Consider a screensaver-type app. I want to display a different "set" of text messages to the network each day. The number of "sets" could very with time. My example is simplified down to 3 "sets".
     
  4. foxidrive

    foxidrive Banned

    Joined:
    Oct 20, 2012
    Messages:
    793
    A random text message can be taken from a single file - the type of message will determine if that's a useful way to do it.

    Or do you want to cycle a set of messages in a single order?
     
  5. DocBenOrdway

    DocBenOrdway Thread Starter

    Joined:
    Jan 25, 2016
    Messages:
    8
    Cycle a set of messages in a single order. Then a different set (say the next day). Then a different set (say the next day). Etc.
     
  6. foxidrive

    foxidrive Banned

    Joined:
    Oct 20, 2012
    Messages:
    793
    So you're planning on having several sets of files?

    With a good description I am fairly certain it can all be contained with one batch file.
    But this is what you asked, I think. It's untested.

    Code:
    ren base.txt base.tmp
    ren 2.txt base.txt
    ren 3.txt 2.txt
    ren base.tmp 3.txt
    
     
  7. DocBenOrdway

    DocBenOrdway Thread Starter

    Joined:
    Jan 25, 2016
    Messages:
    8
    Thank you. That confirms what I thought.

    I tested it, and after a few false starts, it does work.

    I'm now testing it with Task Scheduler.

    Thank you.
     
  8. DocBenOrdway

    DocBenOrdway Thread Starter

    Joined:
    Jan 25, 2016
    Messages:
    8
    Well that didn't go so well and I thought that would be the easy part.

    I successfully tested the .bat file.

    I created a shortcut to test run the .bat file and it worked.

    I set Task Scheduler to run the .bat file. Failure. History says the scheduled task ran. It did not.

    I set Task Scheduler to run (several times) at 10 min. in the future. I see what appears to be the .bat file running but it did not cycle the files.

    Is there a "but" hidden in Task Scheduler?
     
  9. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,783
    How is the scheduled task configured?
     
  10. foxidrive

    foxidrive Banned

    Joined:
    Oct 20, 2012
    Messages:
    793
    It did run, but it did the old "switch to system32 folder" trick.

    The current folder isn't what you think it is - you have to change the folder as the first command, or use explicit paths in the rename command.
     
  11. DocBenOrdway

    DocBenOrdway Thread Starter

    Joined:
    Jan 25, 2016
    Messages:
    8
    General
    Run only when user is logged on [Note: Logged on 24/7]

    Triggers
    Daily
    Start: 1/29/2016 4:00:00 AM
    Recur every: 1 days
    Advanced settings
    Enabled

    Actions
    Start a program: "C:\Utilities\Screensavers\Marquee Plus\Cycle Sayings.bat"
    [Note: Also tried "C:\Cycle_Sayings.bat" with the 3 text files in the same location]

    Conditions
    Start the task only if the computer is in AC power
    Stop if the computer switches to battery power
    [Note: Desktop with UPS]

    Settings
    Allow tasks to be run on demand
    Run tasks as soon as possible after a scheduled start is missed
    Stop the task if it runs longer than: 3 days
    If the running task does not end when requested, force it to stop

    History
    Number of events: 43
    [Note: The Task/Action is listed as completed: 7 times - that includes my tests]
     
  12. foxidrive

    foxidrive Banned

    Joined:
    Oct 20, 2012
    Messages:
    793
    Did you understand this?
     
  13. DocBenOrdway

    DocBenOrdway Thread Starter

    Joined:
    Jan 25, 2016
    Messages:
    8
    My apologizes, I did not get notice of your 2:09 AM posting. I did get the 1:41 PM post and that got this old head remembering more about .bat files that I wrote in the 1980s.

    I specified (cd) the path and ran a test. It appears to work so I have reset the time to 4 AM and We'll see what happens tomorrow.

    Thank you for all your help with something that should have been simpler for me.
     
  14. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Tags:
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1164898

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice