March 15, 2016 at 10:44 am
Hello,
I am planning to implement a script to copy image from one folder to another with sql server script. But I don't want to copy duplicate image.Does it possible to rid off duplicate image?How?
--show advanced configuration on
sp_configure 'show advanced options',1
reconfigure
go
--by default OLE Automation Procedures is off for security concern
--we can enable it by following command
sp_configure 'Ole Automation Procedures',1
reconfigure
go
DECLARE @FsObjId INTEGER
DECLARE @Source VARCHAR(4096)
DECLARE @Destination VARCHAR(4096)
SET @Source = '\\PC04HGFD\c\winDSX\images'
SET @Destination= 'C:\images'
--creare OLE Automation instance
EXEC sp_OACreate 'Scripting.FileSystemObject', @FsObjId OUTPUT
--call method of OLE Automation
EXEC sp_OAMethod @FsObjId, 'CopyFolder', NULL, @Source, @Destination
--once you finish copy, destroy object
EXEC sp_OADestroy @FsObjId
GO
I wrote above script for copy images from one folder to another but I don't know how to deal with duplicate images.
In another words I want to compare files in existing folder and if file doesn't exist than I want to copy that file using sql server management studio
Thanks
March 15, 2016 at 11:07 am
I'm assuming you have two copies of the same image with a different file name, is that correct?
If that's is correct, you'd have to do some sort of checksum comparison. I've never tried, but it looks like there are some tools/apps out there that will do this.
File Checksum Integrity Verifier (FCIV)
Checksum Compare
March 15, 2016 at 11:16 am
yes,same image with different name.Sorry for before reply
March 15, 2016 at 11:32 am
I think you need to provide more details, as there's no way you have 2 of the same file with the same name in the same folder...
There is already a file with the same name in this location
March 15, 2016 at 11:44 am
We have one software which creates student badges.By that way we capture the images.That images stores in image folder. Right now we rename image using firstname,lastname. Now when student badge expires or stolen he will come to renew his badge.So we need to rename student image as his firstname,lastname.Right now I have two same images with different name aleanhnabranch_00001.jpg and aleahnabranch_00003.jpg. I don't want to copy this kind of same images to another folder. Is there any way to implement this?
Thanks
March 15, 2016 at 11:45 am
Yes, same image with different name
March 15, 2016 at 12:32 pm
you'd have to do some sort of checksum comparison
March 15, 2016 at 11:01 pm
RV16 (3/15/2016)
We have one software which creates student badges.By that way we capture the images.That images stores in image folder. Right now we rename image using firstname,lastname. Now when student badge expires or stolen he will come to renew his badge.So we need to rename student image as his firstname,lastname.Right now I have two same images with different name aleanhnabranch_00001.jpg and aleahnabranch_00003.jpg. I don't want to copy this kind of same images to another folder. Is there any way to implement this?Thanks
Sure. After you've loaded the names, sort then in name order descending and select just the top 1 for movement.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2016 at 1:53 pm
The best way to copy student image is using robocopy instead of sql server scripts
So I just used that way:
And now its solved. So I just put answer anyone who wants to refer :
By /XN /XV /XO I can overwrite existing image..
@echo off
robocopy c:\images c:\images2 /XN /XC /XO
Thanks
March 16, 2016 at 5:26 pm
RV16 (3/16/2016)
The best way to copy student image is using robocopy instead of sql server scriptsSo I just used that way:
And now its solved. So I just put answer anyone who wants to refer :
By /XN /XV /XO I can overwrite existing image..
@echo off
robocopy c:\images c:\images2 /XN /XC /XO
Thanks
I'm afraid it would not solve your problem with the same image saved under different names.
Robocopy does not look inside of files, it just deals with file names.
_____________
Code for TallyGenerator
March 16, 2016 at 6:36 pm
RV16 (3/16/2016)
The best way to copy student image is using robocopy instead of sql server scriptsSo I just used that way:
And now its solved. So I just put answer anyone who wants to refer :
By /XN /XV /XO I can overwrite existing image..
@echo off
robocopy c:\images c:\images2 /XN /XC /XO
Thanks
At this point, my question would be... why are you copying to begin with? Want not just redirect your pointers to the correct image?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 17, 2016 at 9:39 am
I already remove same image with different names through del command. We are using one software to make badges. By that software, when our librarian takes a picture of person it create image with random generated number by itself and one image is generated by our librarian so I want to delete that random generated number image.So I just implement del command to remove randomly generated image and now it's solved.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply