Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6705875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:27:17+00:00 2026-05-26T07:27:17+00:00

Help please! I am new to the batch files and have a very specific

  • 0

Help please! I am new to the batch files and have a very specific question. I am trying to copy many files in multiple subdirectories into a single directory via a for loop and in the meantime attache a timestamp to each name (because all the files have the same name). I am using the system variable time and parsing it inside the loop, but the local variables inside the loop get assigned garbage. I already know about delayed expansion and using ! sign instead of %, but that doesnt help me. here is the code:

@echo off
SetLocal EnableDelayedExpansion
set counter=1
echo in the beginning the counter is "%counter%"
:loop
for /r "c:\users\wimdu\dropbox\wimdu CRM\emarsys reports - campaigns" %%f in (bounce*.*) do (
set a = %time::=%
echo in loop a equals "!a!"
echo the time is !time!
set b=!a:,=!

copy /y "%%f" c:\users\wimdu\documents\bouncehandling\bouncecsvfiles\%b%.csv
)
EndLocal

So, basically the names of the files would be 10151821.csv, for instance (time stamp including milliseconds). ideally it would be the original filename (bounces) concatenated with time stamp with .csv extension. I have tried everything but with the timestamp nothing seems to work, a just does not get assigned correctly. And then b as well . I do not know how to parse a and then assign it to b within !! signs. Please help!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:27:18+00:00Added an answer on May 26, 2026 at 7:27 am

    There are multiple problems.
    You didn’t set “a” as you append a space, you set “a “.
    And you always use the same time, as %time% will be expanded only once while parsing the block:.
    The same problem you get with %b%.
    Change both to delayed expansion and it could work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am quite new to programming, i have a question please help me. (
I'm very new to MySQL so I need some help please, I have a
I m very new in spring batch project.I m trying to create a project
Please help me to write a trigger that adds new rows to a table.
I am new in CSS so please help me in this problem. I hope
Please help! Background info I have a WPF application which accesses a SQL Server
Please help me with a sanity check. Assuming a many-to-many relationship: Post, PostTagAssoc, Tag
I am fairly new to writing batch scripts. I am trying to write a
Can anyone please help me on adding new contacts in address book and apply
Please help to prepare batch script on DOS. This script should run in following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.