February 25, 2003 at 3:52 pm
Can some tell me how to rename or copy files in the folder. for example I have a table which contains two fields ID and Photo_ID. I want to rename files which have Photo_id with ID in the folder.
Thanks in advance
February 26, 2003 at 10:24 am
Kind of confusing. Can you provide an example of what you mean?
Steve Jones
February 28, 2003 at 11:58 am
Sorry for making you confuse. I actually figure out the problem. I use xp_cmdshell to solve this problem.
I wanted to rename all the files in the folder with different name based on the table I created. the table has two fields like ID and BM. BM field is replaced by ID.
Here is the code.
Declare @path varchar(100)
set @path = ' \\gmti-it-balbir\c$\balbir\accent\photo\ '
SET NOCOUNT ON
DECLARE @id varchar(10), @bm varchar(10),@str varchar(2000)
DECLARE bmp_cursor CURSOR FOR
SELECT [ID], BM FROM bmp
OPEN bmp_cursor
FETCH NEXT FROM bmp_cursor
INTO @id, @BM
WHILE @@FETCH_STATUS = 0
BEGIN
set @STR = ' rename '+rtrim(@path) + @bm+'.jpg ' + @ID+'.jpg'
exec master..xp_cmdshell @STR
FETCH NEXT FROM bmp_cursor
INTO @ID, @BM
END
CLOSE bmp_cursor
DEALLOCATE bmp_cursor
GO
March 24, 2005 at 10:55 am
I am trying to rename JPGs files in a directory with a barcode. I am able to load a table called imagephoto with the file names of the directory including the .jpg , the field names are photo and barcode all the filenames are in photo in the barcode I have a barcode for each filename. now how do I rename the files in the directory with barcode from the table I tried to use you example but I could not get it to work I dont understand what bmp or bmp_cursor is. is that the name of the table? Could you show me the script.
Thanks Dave Federici
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply