Search found 15 matches

by mcranmer
27 Mar 2012 05:41
Forum: DOS Batch Forum
Topic: Adding folder name to filenames
Replies: 1
Views: 2443

Adding folder name to filenames

I have a large number of folders each containing a number of text files. The folders have generic names like 'UD' or 'KX'. I want to add the name of each folder to the start of all filenames of files within the folder. so files: filename1 filename2 filename3 in folder KX should be renamed: KX_filena...
by mcranmer
16 Mar 2012 11:06
Forum: DOS Batch Forum
Topic: filename datestamp issue
Replies: 20
Views: 12053

Re: filename datestamp issue

thanks eveyone. That gives me plenty to work with. :D
by mcranmer
16 Mar 2012 10:34
Forum: DOS Batch Forum
Topic: filename datestamp issue
Replies: 20
Views: 12053

filename datestamp issue

Why does the following code change a filename from UK3_NEWPOLICY.txt to UK3_NEWPOLICY.txt_16032012.txt?

Code: Select all

Set FileDate=%date:/=%

for %%i in (*.txt) do ren %%i %%i_%FileDate%.txt


I'm obviously getting an additional dot and file extension. What is the reason?

thanks,

Mark
by mcranmer
01 Mar 2012 03:20
Forum: DOS Batch Forum
Topic: removing dots from filenames
Replies: 7
Views: 11177

Re: removing dots from filenames

Great stuff foxidrive!

thanks again. :D

Mark
by mcranmer
29 Feb 2012 07:48
Forum: DOS Batch Forum
Topic: removing dots from filenames
Replies: 7
Views: 11177

Re: removing dots from filenames

These are dates which have been manually added by various colleagues, past and present, and were not automatically generated dates, which explains their haphazard format. I know that the order is always day, month, year. My assumption, however, is that the crucial thing is to strip out a string, whi...
by mcranmer
29 Feb 2012 04:39
Forum: DOS Batch Forum
Topic: removing dots from filenames
Replies: 7
Views: 11177

Re: removing dots from filenames

Hi foxidrive, Your code worked fine, thanks. I am attempting to work out a new problem for myself, but it is taking a while. I want to replace any date-like string in either ddmmyy, dd.mm.yy, ddmmyyyy or dd.mm.yyyy in all filenames to be replaced with the current date in ddmmyy format. I'll continue...
by mcranmer
27 Feb 2012 08:39
Forum: DOS Batch Forum
Topic: string find and replace batch file
Replies: 17
Views: 20681

Re: string find and replace batch file

just discovered that the batch runs perfectly if run locally, rather than on a network drive. So all's well.

thanks
mark :)
by mcranmer
27 Feb 2012 08:14
Forum: DOS Batch Forum
Topic: string find and replace batch file
Replies: 17
Views: 20681

Re: string find and replace batch file

At present it appears to with the first file, whichever is on the list. eg. filename:DF3_RP1_080811.txt contents: header-PolicyDocumentation-100998710 header-policydetails WaitPeriod=14 TotalvalueofDiscounts=£0.00 TotalPreviousValue=£0.00 TotalPremiumPencePerDay=11p TotalPremiumExcServiceCostQtrBF=£...
by mcranmer
27 Feb 2012 07:38
Forum: DOS Batch Forum
Topic: string find and replace batch file
Replies: 17
Views: 20681

Re: string find and replace batch file

by batch file is working in certain folders but not others. I'm curious to know why. It appears to hang on the first file. the folder path is: V:\Mark\PandR\Projects\TestData\T&C\test sample filenames are: B53_RP1_190212.txt D42_RP1_190212.txt DF3_RP1_080811.txt DM3_RP1_190212.txt DY3_RP1_080811...
by mcranmer
27 Feb 2012 07:10
Forum: DOS Batch Forum
Topic: removing dots from filenames
Replies: 7
Views: 11177

removing dots from filenames

Anyone have batch script to remove all dots (except the one preceding the file extension) from filenames, for all .txt files in a directory?

thanks all.

Mark
by mcranmer
26 Feb 2012 08:53
Forum: DOS Batch Forum
Topic: string find and replace batch file
Replies: 17
Views: 20681

Re: string find and replace batch file

PERFECT! Thanks. I am using my new vba expertise at work and have saved the team many days of work by building an appliction which makes various changes to thousands of text files based on regex pattern matching, but only just realised that my application is adding a carriage return. This batch file...
by mcranmer
26 Feb 2012 05:21
Forum: DOS Batch Forum
Topic: string find and replace batch file
Replies: 17
Views: 20681

Re: string find and replace batch file

I'm hugely impressed with your code, and am learning a lot from studying it. I'd like to tweak your code so that removes all empty rows, including all carriage returns at the end of the text file. I have found code which performs this function on a single file and outputs the result to a new file. I...
by mcranmer
26 Feb 2012 05:06
Forum: DOS Batch Forum
Topic: string find and replace batch file
Replies: 17
Views: 20681

Re: string find and replace batch file

thanks! That was a huge help.

mark
by mcranmer
20 Feb 2012 11:33
Forum: DOS Batch Forum
Topic: string find and replace batch file
Replies: 17
Views: 20681

Re: string find and replace batch file

Just found this link in the DosTips examples, and will take a look:


http://www.dostips.com/DtCodeBatchFiles ... AndReplace
by mcranmer
20 Feb 2012 11:07
Forum: DOS Batch Forum
Topic: string find and replace batch file
Replies: 17
Views: 20681

string find and replace batch file

I am wanting to build a batch file which finds and replaces a given string in over a hundred text files. I have plucked this code from the web but all it does it open the text file in the BATCHTEST folder. This BATCHTEST folder contains a test text file which contains only the word BOB. The code is ...